vendure icon indicating copy to clipboard operation
vendure copied to clipboard

Put all tables in specified schema("vendure") can integrate with exist old DB database

Open roytan883 opened this issue 2 years ago • 4 comments

Is your feature request related to a problem? Please describe. The DB tables in postgres currently is in default "public" schema. Can I change it to a custom schema?

Describe the solution you'd like When create the project with postgres , after input database name (which can be exist exist DB database name), then ask using which schema (default "public“ or ”vendure" ?)

Additional context Put all vendure tables in specified schema("vendure") with exist old DB database. Then my "basic.basic_user" table can work with "vendure.user" table, do some join query stuff.

roytan883 avatar Jul 18 '22 10:07 roytan883

I found "readonly schema?: string" in "PostgresConnectionOptions" in "typeorm/src/driver/postgres/". Here: https://github.com/typeorm/typeorm/blob/master/src/driver/postgres/PostgresConnectionOptions.ts

"VendureConfig.dbConnectionOptions object. This object is actually the TypeORM configuration object and is passed directly to TypeORM." I will test it tomorrow.

roytan883 avatar Jul 18 '22 18:07 roytan883

The schema worked in new database. But has error with old database for first time, then the error disappear when run second time.

QueryFailedError: duplicate key value violates unique constraint "pg_type_typname_nsp_index"
    at QueryFailedError.TypeORMError [as constructor] (/home/rtsu16/rts-server/rts-module-shop-vendure/server/node_modules/typeorm/error/TypeORMError.js:9:28)
    at new QueryFailedError (/home/rtsu16/rts-server/rts-module-shop-vendure/server/node_modules/typeorm/error/QueryFailedError.js:13:28)
    at PostgresQueryRunner.<anonymous> (/home/rtsu16/rts-server/rts-module-shop-vendure/server/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:250:31)
    at step (/home/rtsu16/rts-server/rts-module-shop-vendure/server/node_modules/typeorm/node_modules/tslib/tslib.js:144:27)
    at Object.throw (/home/rtsu16/rts-server/rts-module-shop-vendure/server/node_modules/typeorm/node_modules/tslib/tslib.js:125:57)
    at rejected (/home/rtsu16/rts-server/rts-module-shop-vendure/server/node_modules/typeorm/node_modules/tslib/tslib.js:116:69)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

roytan883 avatar Jul 18 '22 18:07 roytan883

@michaelbromley How can i add set "schema" step when creating project? I use "yarn create @vendure xxx"

roytan883 avatar Jul 18 '22 18:07 roytan883

It's not supported yet, but I've added it to the milestone for the next minor release.

michaelbromley avatar Jul 19 '22 08:07 michaelbromley