drizzle kit not migrating to turso properly

I have this little app with this schema
https://github.com/nevthereal/codoodle/blob/main/src/lib/server/db/schema.ts
And if I generate an sql file it will output something different, meaning not in the same order. First the posts table, then sessions and on the bottom users. I don't know if the order actually affects the migration, but i think it does.
When I run the migration I always get some libsql error with the code 500. Important to note: my db on turso was created with --type schema if this has any importance. but anyways. Always when I want to run the migration, I get this 500 error code:
LibsqlError: SERVER_ERROR: Server returned HTTP status 500
    at mapHranaError (file:///Users/nevillebrem/Developer/Projects/codoodle/node_modules/@libsql/client/lib-esm/hrana.js:257:16)
    at HttpClient.execute (file:///Users/nevillebrem/Developer/Projects/codoodle/node_modules/@libsql/client/lib-esm/http.js:53:19)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.run (/Users/nevillebrem/Developer/Projects/codoodle/node_modules/drizzle-kit/bin.cjs:111592:15)
    at async sqlitePush (/Users/nevillebrem/Developer/Projects/codoodle/node_modules/drizzle-kit/bin.cjs:114608:13)
    at async Command.<anonymous> (/Users/nevillebrem/Developer/Projects/codoodle/node_modules/drizzle-kit/bin.cjs:121490:7) {
  code: 'SERVER_ERROR',
  rawCode: undefined,
  [cause]: HttpServerError: Server returned HTTP status 500
      at errorFromResponse (file:///Users/nevillebrem/Developer/Projects/codoodle/node_modules/@libsql/hrana-client/lib-esm/http/stream.js:363:12)
      at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
    status: 500
  }
}

if i then go to turso.tech/app to view the tables in their embedded drizzle studio i get this message:
Cannot read properties of undefined (reading 'id')
and if i use local drizzle studio, i only see the posts table.
GitHub
A SvelteKit blog with Turso. Contribute to nevthereal/codoodle development by creating an account on GitHub.
Was this page helpful?