You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After making a change to the schema, and running drizzle-kit push:sqlite, Requests made from my application started getting the following error:
⨯ Internal error: SqliteError: no such table: main.__old_push_[table name]
at Database.prepare ([path to project]\node_modules\.pnpm\better-sqlite3@9.5.0\node_modules\better-sqlite3\lib\methods\wrappers.js:5:21)
at BetterSQLiteSession.prepareQuery (./node_modules/.pnpm/drizzle-orm@0.30.8_@types+better-sqlite3@7.6.9_@types+react@18.2.79_better-sqlite3@9.5.0_react@18.2.0/node_modules/drizzle-orm/better-sqlite3/session.js:28:30)
at BetterSQLiteSession.prepareOneTimeQuery (./node_modules/.pnpm/drizzle-orm@0.30.8_@types+better-sqlite3@7.6.9_@types+react@18.2.79_better-sqlite3@9.5.0_react@18.2.0/node_modules/drizzle-orm/sqlite-core/session.js:76:17)
at QueryPromise._prepare (./node_modules/.pnpm/drizzle-orm@0.30.8_@types+better-sqlite3@7.6.9_@types+react@18.2.79_better-sqlite3@9.5.0_react@18.2.0/node_modules/drizzle-orm/sqlite-core/query-builders/insert.js:135:81)
at QueryPromise.run (./node_modules/.pnpm/drizzle-orm@0.30.8_@types+better-sqlite3@7.6.9_@types+react@18.2.79_better-sqlite3@9.5.0_react@18.2.0/node_modules/drizzle-orm/sqlite-core/query-builders/insert.js:146:17)
at QueryPromise.execute (./node_modules/.pnpm/drizzle-orm@0.30.8_@types+better-sqlite3@7.6.9_@types+react@18.2.79_better-sqlite3@9.5.0_react@18.2.0/node_modules/drizzle-orm/sqlite-core/query-builders/insert.js:158:54)
at QueryPromise.then (./node_modules/.pnpm/drizzle-orm@0.30.8_@types+better-sqlite3@7.6.9_@types+react@18.2.79_better-sqlite3@9.5.0_react@18.2.0/node_modules/drizzle-orm/query-promise.js:26:17)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
digest: "3629522731"
The root cause of this error is the fact that the foriegn key values set up using the .references(()=>table.id) syntax in the schema are not being properly migrated, and are left referencing the _old_push version of the target table (which I assume only exists for a short time during the push:sqlite process)
Work Around:
The foriegn keys were not really neccessary in my case, so I just removed the .references() calls in the schema and everything works now, but I imagine that wont be a good solution for everyone.
The text was updated successfully, but these errors were encountered:
Following. I get this a lot using local Turso dev. I end up having to recreate the local SQLite db and push from scratch but with so many changes whilst in dev, it gets frustrating. It's normally when I make changes to the relationships or the columns.
+1. Same error running drizzle-kit push:sqlite with Turso. Very frustrating experience while on dev, as I have to instantiate new db on every schema changes for push:sqlite to run properly.
The Issue:
After making a change to the schema, and running drizzle-kit push:sqlite, Requests made from my application started getting the following error:
Environment
drizzle-kit version: 0.20.17
drizzle-orm version: 0.30.8
framework: NextJS
Identified Bug:
The root cause of this error is the fact that the foriegn key values set up using the .references(()=>table.id) syntax in the schema are not being properly migrated, and are left referencing the _old_push version of the target table (which I assume only exists for a short time during the push:sqlite process)
Work Around:
The foriegn keys were not really neccessary in my case, so I just removed the .references() calls in the schema and everything works now, but I imagine that wont be a good solution for everyone.
The text was updated successfully, but these errors were encountered: