Drizzle turso configuration not working

Hi! No matter what i change in my schema, i get errors. Only if i drop all tables. i can successfully push again. Even just simple changes to schema doesn't work. I've tried multiple version of the t3 stack and have never got it working properly. What am i doing wrong? Here is an example of an error i get: terminal
@repo/db:db:push: TypeError: Cannot read properties of undefined (reading 'primaryKey')
@repo/db:db:push: at logSuggestionsAndReturn2 (/Users/gaden/Documents/GitHub/flashcards/node_modules/drizzle-kit/bin.cjs:72915:87)
@repo/db:db:push: at sqlitePush (/Users/gaden/Documents/GitHub/flashcards/node_modules/drizzle-kit/bin.cjs:74866:19)
@repo/db:db:push: at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
@repo/db:db:push: at async Object.handler (/Users/gaden/Documents/GitHub/flashcards/node_modules/drizzle-kit/bin.cjs:83724:9)
@repo/db:db:push: at async run (/Users/gaden/Documents/GitHub/flashcards/node_modules/drizzle-kit/bin.cjs:82064:7)
@repo/db:db:push: TypeError: Cannot read properties of undefined (reading 'primaryKey')
@repo/db:db:push: at logSuggestionsAndReturn2 (/Users/gaden/Documents/GitHub/flashcards/node_modules/drizzle-kit/bin.cjs:72915:87)
@repo/db:db:push: at sqlitePush (/Users/gaden/Documents/GitHub/flashcards/node_modules/drizzle-kit/bin.cjs:74866:19)
@repo/db:db:push: at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
@repo/db:db:push: at async Object.handler (/Users/gaden/Documents/GitHub/flashcards/node_modules/drizzle-kit/bin.cjs:83724:9)
@repo/db:db:push: at async run (/Users/gaden/Documents/GitHub/flashcards/node_modules/drizzle-kit/bin.cjs:82064:7)
packages/db/drizzle.config.ts
import { type Config } from "drizzle-kit";
import { env } from "@repo/env";

export default {
schema: "./schema.ts",
dialect: "sqlite",
driver: "turso",
out: "./migrations",
dbCredentials: {
url: env.TURSO_CONNECTION_URL!,
authToken: env.TURSO_AUTH_TOKEN!,
},
tablesFilter: ["flashcards_*"],
} satisfies Config;
import { type Config } from "drizzle-kit";
import { env } from "@repo/env";

export default {
schema: "./schema.ts",
dialect: "sqlite",
driver: "turso",
out: "./migrations",
dbCredentials: {
url: env.TURSO_CONNECTION_URL!,
authToken: env.TURSO_AUTH_TOKEN!,
},
tablesFilter: ["flashcards_*"],
} satisfies Config;
packages/db/package.json
{
"name": "@repo/db",
"module": "index.ts",
"type": "module",
"scripts": {
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:push": "drizzle-kit push",
"db:studio": "drizzle-kit studio"
},
"dependencies": {
"@libsql/client": "^0.14.0",
"drizzle-orm": "^0.33.0"
},
"devDependencies": {
"@types/bun": "latest",
"drizzle-kit": "^0.24.2"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
{
"name": "@repo/db",
"module": "index.ts",
"type": "module",
"scripts": {
"db:generate": "drizzle-kit generate",
"db:migrate": "drizzle-kit migrate",
"db:push": "drizzle-kit push",
"db:studio": "drizzle-kit studio"
},
"dependencies": {
"@libsql/client": "^0.14.0",
"drizzle-orm": "^0.33.0"
},
"devDependencies": {
"@types/bun": "latest",
"drizzle-kit": "^0.24.2"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
packages/db/index.ts
import { createClient, type Client } from "@libsql/client";
import { drizzle } from "drizzle-orm/libsql";
import { config } from "dotenv";
import { env } from "@repo/env";
import * as schema from "./schema";

config({ path: ".env" });

/**
* Cache the database connection in development. This avoids creating a new connection on every HMR
* update.
*/
const globalForDb = globalThis as unknown as {
client: Client | undefined;
};

export const client =
globalForDb.client ??
createClient({
url: process.env.TURSO_CONNECTION_URL!,
authToken: process.env.TURSO_AUTH_TOKEN!,
});
if (env.NODE_ENV !== "production") globalForDb.client = client;

export const db = drizzle(client, { schema });
import { createClient, type Client } from "@libsql/client";
import { drizzle } from "drizzle-orm/libsql";
import { config } from "dotenv";
import { env } from "@repo/env";
import * as schema from "./schema";

config({ path: ".env" });

/**
* Cache the database connection in development. This avoids creating a new connection on every HMR
* update.
*/
const globalForDb = globalThis as unknown as {
client: Client | undefined;
};

export const client =
globalForDb.client ??
createClient({
url: process.env.TURSO_CONNECTION_URL!,
authToken: process.env.TURSO_AUTH_TOKEN!,
});
if (env.NODE_ENV !== "production") globalForDb.client = client;

export const db = drizzle(client, { schema });
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server