cds-dbm icon indicating copy to clipboard operation
cds-dbm copied to clipboard

error: relation "csw_breweryanalytics" does not exist when runing cds-dbm inside pg-beershop docker container

Open gregorwolf opened this issue 3 years ago • 3 comments

Hi @mikezaschka,

I try to get the Kyma deployment of pg-beershop more automated. For that I've added openjdk-11-jre to the Docker Image to be able to run cds-dbm. But when running:

npx cds-dbm deploy --create-db --load-via delta

inside the docker container I get the following error:

[cds-dbm] - starting delta database deployment of service db
[cds-dbm] - database beershop is already present
cds-dbm deploy [services]

Dynamically identifies changes in your cds data model and deploys them to the
database

Options:
      --help           Show help                                       [boolean]
      --version        Show version number                             [boolean]
  -s, --service                                                [default: ["db"]]
  -a, --auto-undeploy
  -d, --dry
  -l, --load-via
  -c, --create-db

{ error: relation "csw_breweryanalytics" does not exist
    at Parser.parseErrorMessage (/usr/src/app/node_modules/pg/node_modules/pg-protocol/dist/parser.js:287:98)
    at Parser.handlePacket (/usr/src/app/node_modules/pg/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/usr/src/app/node_modules/pg/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket.stream.on (/usr/src/app/node_modules/pg/node_modules/pg-protocol/dist/index.js:11:42)
    at Socket.emit (events.js:198:13)
    at addChunk (_stream_readable.js:288:12)
    at readableAddChunk (_stream_readable.js:269:11)
    at Socket.Readable.push (_stream_readable.js:224:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
  length: 120,
  name: 'error',
  severity: 'ERROR',
  code: '42P01',
  detail: undefined,
  hint: undefined,
  position: '178',
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'parse_relation.c',
  line: '1376',
  routine: 'parserOpenTable' }

You can replicate the issue when you clone pg-beershop and run the following commands:

npm i
npm run build:docker
npm run docker:start:pg
npm run docker:start:cds
npm run docker:shell

On the shell of the docker container run:

npx cds-dbm deploy --create-db --load-via delta

Looking forward for your help. Is there any debug option I can enable? exporting DEBUG=debug did not produce more output.

Best regards Gregor

gregorwolf avatar Apr 18 '21 16:04 gregorwolf

Hi @gregorwolf,

I recently applied a fix to cds-dbm to reorder the generated views correctly. The issue should be gone now.

Kind Regards, Mike

mikezaschka avatar Jun 27 '21 18:06 mikezaschka

Hi Mike,

I am also receiving same kind of error.

'Starting Liquibase at 17:57:15 (version 4.1.0 #3 built at 2020-09-28 21:02+0000)\r\n' + 'Unexpected error running Liquibase: Migration failed for change set tmp/_autodeploy.json::1627302434692-4::rbhuva (generated):\n' + ' Reason: liquibase.exception.DatabaseException: ERROR: relation "coreexch_sourcesystype" already exists [Failed SQL: (0) CREATE TABLE public.coreexch_sourcesystype (systype VARCHAR(8) NOT NULL, description VARCHAR(128), CONSTRAINT tjc_coreexch_sourcesystype_pkey PRIMARY KEY (systype))]\r\n' + 'For more information, please use the --logLevel flag\r\n'

Error appeared when i retry to fix deployment errors.

Need to execute npx cds-dbm drop all to clear DB in case of any errors in deployment.

Kind Regards, Rajdeep Bhuva

rbhuva avatar Jul 26 '21 12:07 rbhuva

Hi Mike,

It is resolved now. It was because of other schema name in default schema. After changing it to "public", it is working fine.

Thanks, Rajdeep Bhuva

rbhuva avatar Sep 01 '21 05:09 rbhuva