benjick
benjick
Explore posts from servers
DTDrizzle Team
Created by benjick on 6/1/2024 in #help
Noob question about DROP TABLE ordering
Yeah I just moved the DROP statement to the end of the file manually
4 replies
DTDrizzle Team
Created by benjick on 6/1/2024 in #help
Noob question about DROP TABLE ordering
Yeah, got this error:
error: cannot drop table merlin_schools because other objects depend on it
4 replies
DTDrizzle Team
Created by benjick on 5/28/2024 in #help
drizzle-kit push fails every second time
Removed it and it work now, sorry
4 replies
DTDrizzle Team
Created by benjick on 5/28/2024 in #help
drizzle-kit push fails every second time
I guess I can remove it, since it's already a PK
4 replies
DTDrizzle Team
Created by benjick on 5/28/2024 in #help
drizzle-kit push fails every second time
Here's the schema:
export const taskId = pgTypeId("task_id")
.primaryKey()
.references(() => tasks.id, {
onDelete: "cascade",
});

export const publishedTasks = pgTable(
"published_tasks",
{
taskId,
duplicateCount: integer("duplicate_count").notNull().default(0),
instanceCount: integer("instance_count").notNull().default(0),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow(),
},
(table) => {
return {
taskIdIdx: unique("pt_task_id_idx").on(table.taskId),
};
},
);
export const taskId = pgTypeId("task_id")
.primaryKey()
.references(() => tasks.id, {
onDelete: "cascade",
});

export const publishedTasks = pgTable(
"published_tasks",
{
taskId,
duplicateCount: integer("duplicate_count").notNull().default(0),
instanceCount: integer("instance_count").notNull().default(0),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow(),
},
(table) => {
return {
taskIdIdx: unique("pt_task_id_idx").on(table.taskId),
};
},
);
pgTypeId is just a varchar with a max length
4 replies
DTDrizzle Team
Created by Icemourne on 3/11/2024 in #help
Can someone explain how can I use .onConflictDoUpdate with array of values?
TIL, thank you!
5 replies
DTDrizzle Team
Created by Icemourne on 3/11/2024 in #help
Can someone explain how can I use .onConflictDoUpdate with array of values?
The SET and WHERE clauses in ON CONFLICT DO UPDATE have access to the existing row using the table's name (or an alias), and to rows proposed for insertion using the special excluded table
5 replies
DTDrizzle Team
Created by Icemourne on 3/11/2024 in #help
Can someone explain how can I use .onConflictDoUpdate with array of values?
excluded = the current iteration?
5 replies
DTDrizzle Team
Created by benjick on 11/29/2023 in #help
Property '[IsDrizzleTable]' is missing in type
I'm not using deno
11 replies
DTDrizzle Team
Created by benjick on 11/29/2023 in #help
Property '[IsDrizzleTable]' is missing in type
Here's is the table itself:
export const groupCategories = pgTable("group_categories", {
id: pgTypeId("gc").primaryKey(),
groupId,
name: varchar("name", { length: 256 }).notNull(),
public: boolean("public").notNull().default(false),
defaultCollapsed: boolean("default_collapsed").notNull().default(true),
sortIndex: integer("sort_index").notNull().default(0),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow(),
});
export const groupCategories = pgTable("group_categories", {
id: pgTypeId("gc").primaryKey(),
groupId,
name: varchar("name", { length: 256 }).notNull(),
public: boolean("public").notNull().default(false),
defaultCollapsed: boolean("default_collapsed").notNull().default(true),
sortIndex: integer("sort_index").notNull().default(0),
createdAt: timestamp("created_at").defaultNow().notNull(),
updatedAt: timestamp("updated_at").defaultNow(),
});
11 replies
DTDrizzle Team
Created by benjick on 10/24/2023 in #help
column "summary" cannot be cast automatically to type jsonb
Do I need this? --> statement-breakpoint
10 replies
DTDrizzle Team
Created by benjick on 10/24/2023 in #help
column "summary" cannot be cast automatically to type jsonb
Do you think this looks ok?
ALTER TABLE "merlin_task_results" DROP COLUMN "summary";
ALTER TABLE "merlin_task_results" ADD COLUMN "summary" jsonb DEFAULT '{}' NOT NULL;
ALTER TABLE "merlin_task_results" DROP COLUMN "summary";
ALTER TABLE "merlin_task_results" ADD COLUMN "summary" jsonb DEFAULT '{}' NOT NULL;
10 replies
DTDrizzle Team
Created by benjick on 10/24/2023 in #help
column "summary" cannot be cast automatically to type jsonb
Sorry 🤦
error: column "summary" cannot be cast automatically to type jsonb
at /app/node_modules/pg/lib/client.js:526:17
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /app/.next/server/chunks/38.js:7:328
at async NodePgSession.transaction (/app/.next/server/chunks/38.js:7:40652)
at async PgDialect.migrate (/app/.next/server/chunks/38.js:7:214)
at async migrate (/app/.next/server/chunks/38.js:7:42813)
at async /app/.next/server/chunks/4144.js:1:1007 {
length: 181,
severity: 'ERROR',
code: '42804',
detail: undefined,
hint: 'You might need to specify "USING summary::jsonb".',
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'tablecmds.c',
line: '12302',
routine: 'ATPrepAlterColumnType'
}
error: column "summary" cannot be cast automatically to type jsonb
at /app/node_modules/pg/lib/client.js:526:17
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async /app/.next/server/chunks/38.js:7:328
at async NodePgSession.transaction (/app/.next/server/chunks/38.js:7:40652)
at async PgDialect.migrate (/app/.next/server/chunks/38.js:7:214)
at async migrate (/app/.next/server/chunks/38.js:7:42813)
at async /app/.next/server/chunks/4144.js:1:1007 {
length: 181,
severity: 'ERROR',
code: '42804',
detail: undefined,
hint: 'You might need to specify "USING summary::jsonb".',
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file: 'tablecmds.c',
line: '12302',
routine: 'ATPrepAlterColumnType'
}
10 replies
DTDrizzle Team
Created by hirefrank on 7/11/2023 in #help
Sqlite3 support for Deno
I have the same issue, but I'm using bun:sqlite (but not as driver, since it doesn't exist)
13 replies
DTDrizzle Team
Created by NotLuksus on 8/2/2023 in #help
ReferenceError: Cannot access 'addon' before initialization
This issue is due to circular circular dependencies. For me I had an enum which was imported into one file and then another, so I just extracted it to its own file which cleared it up
32 replies