strapi / migration-scripts

Collection of Strapi Migration scripts
58 stars 58 forks source link

Reset Table Sequence has a syntax error on PostgreSQL #62

Closed colearendt closed 2 years ago

colearendt commented 2 years ago

https://github.com/strapi/migration-scripts/blob/9ce036217a0bb8daef65523f1e5e6c56602b279a/v3-sql-v4-sql/migrate/helpers/migrate.js#L153-L161

On PostgreSQL (have not tried other backends), table references should use " instead of '.

yarn run v1.22.18
$ node index.js
Migrating Core Store
Migrating 18/32 items from core_store to strapi_core_store_settings
core_store batch #1
(node:64141) UnhandledPromiseRejectionWarning: error: SELECT SETVAL ('strapi_core_store_settings_id_seq', (SELECT MAX(id) + 1 FROM 'strapi_core_store_settings')) - syntax error at or near "'strapi_core_store_settings'"
    at Parser.parseErrorMessage (/Users/colearendt/working/strapi-migration-scripts/v3-sql-v4-sql/node_modules/pg-protocol/dist/parser.js:287:98)
    at Parser.handlePacket (/Users/colearendt/working/strapi-migration-scripts/v3-sql-v4-sql/node_modules/pg-protocol/dist/parser.js:126:29)
    at Parser.parse (/Users/colearendt/working/strapi-migration-scripts/v3-sql-v4-sql/node_modules/pg-protocol/dist/parser.js:39:38)
    at Socket.<anonymous> (/Users/colearendt/working/strapi-migration-scripts/v3-sql-v4-sql/node_modules/pg-protocol/dist/index.js:11:42)
    at Socket.emit (events.js:315:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:188:23)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:64141) 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:64141) [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.
NguyenSon2310 commented 2 years ago

yarn run v1.22.19 $ node index.js Migrating Core Store Migrating 355/777 items from core_store to strapi_core_store_settings core_store batch #1 core_store batch #2 core_store batch #3 core_store batch #4 core_store batch #5 core_store batch #6 core_store batch #7 core_store batch #8 (node:83930) UnhandledPromiseRejectionWarning: error: SELECT SETVAL ('strapi_core_store_settings_id_seq', (SELECT MAX(id) + 1 FROM 'strapi_core_store_settings')) - syntax error at or near "'strapi_core_store_settings'" at Parser.parseErrorMessage (/home/nguyenson/migration-scripts/v3-sql-v4-sql/node_modules/pg-protocol/dist/parser.js:287:98) at Parser.handlePacket (/home/nguyenson/migration-scripts/v3-sql-v4-sql/node_modules/pg-protocol/dist/parser.js:126:29) at Parser.parse (/home/nguyenson/migration-scripts/v3-sql-v4-sql/node_modules/pg-protocol/dist/parser.js:39:38) at Socket. (/home/nguyenson/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:83930) 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:83930) [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.

I have same issue with you

MightyDjinn commented 2 years ago

We are running into this issue as well. Any workaround?

jpbast commented 2 years ago

I'm having this same error too

NguyenSon2310 commented 2 years ago

Hi guys, you can use this custom repo for migrate postgres v3 to v4, make sure clean all table in schema v4 and init them by yarn develop before run scripts https://github.com/vitormanfredini/strapi-v3tov4-modified-migration-scripts