Derock
Derock
Explore posts from servers
DTDrizzle Team
Created by Derock on 5/15/2024 in #help
need help with drizzle transactions and foreign key constraints
No description
8 replies
DTDrizzle Team
Created by Derock on 4/28/2024 in #help
cannot migrate database: PostgresError: unterminated /* comment at or near "/*
No description
1 replies
DTDrizzle Team
Created by Derock on 4/27/2024 in #help
ts: Object literal may only specify known properties except the property is known
No description
5 replies
DTDrizzle Team
Created by Derock on 4/23/2024 in #help
SQLite: set fk constraint to be "DEFERRABLE INITIALLY DEFERRED"
I would like to use this feature of sqlite, but I don't see it mentioned anywhere in the docs. A quick search shows that there's an open issue (#1429) but no progress has been made. Are there any temporary workarounds to this? Like can I add in my own SQL to the end of a column definition?
3 replies
DTDrizzle Team
Created by Derock on 12/19/2023 in #help
`no such table: main.__old_push_projects` after db push
Added the following to a table named service:
(table) => ({
name_project_idx: index("name_project_idx").on(table.name, table.projectId),
name_project_unq: unique("name_project_unq").on(
table.name,
table.projectId,
),
}),
(table) => ({
name_project_idx: index("name_project_idx").on(table.name, table.projectId),
name_project_unq: unique("name_project_unq").on(
table.name,
table.projectId,
),
}),
and ran pnpm drizzle-kit push:sqlite it warned:
 Warning  Found data-loss statements:
· You're about to delete __old_push_projects table with 4 items

THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED

Do you still want to push changes?
[✓] Changes applied
 Warning  Found data-loss statements:
· You're about to delete __old_push_projects table with 4 items

THIS ACTION WILL CAUSE DATA LOSS AND CANNOT BE REVERTED

Do you still want to push changes?
[✓] Changes applied
__old_push_projects is never mentioned in my codebase. I have a table named projects, and thats the closest thing. now my server errors with:
"no such table: main.__old_push_projects"
What is this table supposed to be and how can I get it back?
19 replies
DTDrizzle Team
Created by Derock on 11/2/2023 in #help
How do I load sqlite extensions for drizzle-kit?
In my code, when I want to use drizzle I am doing the following:
const sqlite = new SQLite3(env.DATABASE_PATH);

// enable WAL mode
sqlite.pragma("journal_mode = WAL");

// load uuidv7 extension
// built from https://github.com/craigpastro/sqlite-uuidv7
sqlite.loadExtension(
env.SQLITE_UUIDV7_EXT_PATH ??
join(__dirname, "../../../exts/sqlite-uuidv7.so"),
);

export const db = drizzle(sqlite);
const sqlite = new SQLite3(env.DATABASE_PATH);

// enable WAL mode
sqlite.pragma("journal_mode = WAL");

// load uuidv7 extension
// built from https://github.com/craigpastro/sqlite-uuidv7
sqlite.loadExtension(
env.SQLITE_UUIDV7_EXT_PATH ??
join(__dirname, "../../../exts/sqlite-uuidv7.so"),
);

export const db = drizzle(sqlite);
to test my application, I want to use drizzle-kit to create my database, so I created a drizzle.config.ts
import type { Config } from "drizzle-kit";
import { env } from "~/env.mjs";

export default {
schema: "./src/server/db/schema.ts",
driver: "better-sqlite",
dbCredentials: {
url: env.DATABASE_PATH,
},
} satisfies Config;
import type { Config } from "drizzle-kit";
import { env } from "~/env.mjs";

export default {
schema: "./src/server/db/schema.ts",
driver: "better-sqlite",
dbCredentials: {
url: env.DATABASE_PATH,
},
} satisfies Config;
but when I run drizzle-kit push:sqlite, I get SqliteError: near "(": syntax error and I think this is because for some of my tables I have .default(sql`uuid_generate_v7()`) but that function only exists when the sqlite extension is loaded which it isnt when Im running drizzle kit
4 replies