strapi / migration-scripts

Collection of Strapi Migration scripts
58 stars 58 forks source link

Environment variables schema not working #35

Closed jweb89 closed 2 years ago

jweb89 commented 2 years ago

Bug report

Required System information

Describe the bug

Database schema in environment variables does not work properly.

Steps to reproduce the behavior

Use a schema other than public and run the v3-sql-v4-sql script

Expected behavior

To use the right schema

Screenshots

If applicable, add screenshots to help explain your problem.

Code snippets

UnhandledPromiseRejectionWarning: error: delete from "admin_permissions_role_links" - relation "admin_permissions_role_links" does not exist

Many of these errors when trying to run the script. If I prepend the table names in the code with the schema it works. The environment variable schema is "strapi"

derrickmehaffy commented 2 years ago

Hi @jweb89 can you test my branch assigned to PR #41 ?

Thanks!

jweb89 commented 2 years ago

Hi @derrickmehaffy thanks for looking into this. I will test it and get back to you next week. Thanks!

jweb89 commented 2 years ago

Hey @derrickmehaffy I'm still getting the same issue.

Migrating Core Store TBA
Migrating 92/187 items from core_store to strapi_core_store_settings
(node:58790) UnhandledPromiseRejectionWarning: error: select * from "strapi_core_store_settings" where "key" = $1 limit $2 - relation "strapi_core_store_settings" does not exist
    at Parser.parseErrorMessage (/Users/joshweber/migration-scripts/v3-sql-v4-sql/node_modules/pg-protocol/dist/parser.js:287:98)
    at Parser.handlePacket (/Users/joshweber/migration-scripts/v3-sql-v4-sql/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/Users/joshweber/migration-scripts/v3-sql-v4-sql/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket.<anonymous> (/Users/joshweber/migration-scripts/v3-sql-v4-sql/node_modules/pg-protocol/dist/index.js:11:42)
    at Socket.emit (events.js:400:28)
    at addChunk (internal/streams/readable.js:293:12)
    at readableAddChunk (internal/streams/readable.js:267:9)
    at Socket.Readable.push (internal/streams/readable.js:206:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:58790) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)
(node:58790) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

The exact thing I am trying to do is move our existing v3 database which is in public to a new schema called strapi for v4. It looks like it's not finding the table even though it exists after starting the strapi admin on that schema

derrickmehaffy commented 2 years ago

:thinking: Alright I'll try taking another look once I get a moment.

martincapek commented 2 years ago

Hi @jweb89 Can you please try https://github.com/strapi/migration-scripts/pull/54? It should be fixed I did same as you said and the migration works for me. Thanks!

jweb89 commented 2 years ago

We actually finished migrating to v4! I Just did the migration to public schema and then renamed the schema to what I wanted. So if it's working for you safe to say it's fixed. Thanks!