thdxr
thdxr
Explore posts from servers
DTDrizzle Team
Created by thdxr on 11/10/2023 in #help
Dropping primary keys every time
so latest drizzle-kit fixed a bunch of issues with dropping indexes and preserving pk order but it's still dropping and recreating PKs every time
ALTER TABLE `account` DROP PRIMARY KEY;
ALTER TABLE `app` DROP PRIMARY KEY;
ALTER TABLE `aws_account` DROP PRIMARY KEY;
ALTER TABLE `issue` DROP PRIMARY KEY;
ALTER TABLE `issue_alert` DROP PRIMARY KEY;
ALTER TABLE `issue_alert_limit` DROP PRIMARY KEY;
ALTER TABLE `issue_count` DROP PRIMARY KEY;
ALTER TABLE `issue_subscriber` DROP PRIMARY KEY;
ALTER TABLE `lambda_payload` DROP PRIMARY KEY;
ALTER TABLE `log_poller` DROP PRIMARY KEY;
ALTER TABLE `log_search` DROP PRIMARY KEY;
ALTER TABLE `replicache_client` DROP PRIMARY KEY;
ALTER TABLE `replicache_cvr` DROP PRIMARY KEY;
ALTER TABLE `resource` DROP PRIMARY KEY;
ALTER TABLE `slack_team` DROP PRIMARY KEY;
ALTER TABLE `stage` DROP PRIMARY KEY;
ALTER TABLE `stripe` DROP PRIMARY KEY;
ALTER TABLE `usage` DROP PRIMARY KEY;
ALTER TABLE `user` DROP PRIMARY KEY;
ALTER TABLE `warning` DROP PRIMARY KEY;
ALTER TABLE `workspace` DROP PRIMARY KEY;
ALTER TABLE `account` ADD PRIMARY KEY(`id`);
ALTER TABLE `app` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `aws_account` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `issue` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `issue_alert` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `issue_alert_limit` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `issue_count` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `issue_subscriber` ADD PRIMARY KEY(`workspace_id`,`stage_id`,`id`);
ALTER TABLE `lambda_payload` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `log_poller` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `log_search` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `replicache_client` ADD PRIMARY KEY(`id`);
ALTER TABLE `replicache_cvr` ADD PRIMARY KEY(`client_group_id`,`id`);
ALTER TABLE `resource` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `slack_team` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `stage` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `stripe` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `usage` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `user` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `warning` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `workspace` ADD PRIMARY KEY(`id`);
ALTER TABLE `account` DROP PRIMARY KEY;
ALTER TABLE `app` DROP PRIMARY KEY;
ALTER TABLE `aws_account` DROP PRIMARY KEY;
ALTER TABLE `issue` DROP PRIMARY KEY;
ALTER TABLE `issue_alert` DROP PRIMARY KEY;
ALTER TABLE `issue_alert_limit` DROP PRIMARY KEY;
ALTER TABLE `issue_count` DROP PRIMARY KEY;
ALTER TABLE `issue_subscriber` DROP PRIMARY KEY;
ALTER TABLE `lambda_payload` DROP PRIMARY KEY;
ALTER TABLE `log_poller` DROP PRIMARY KEY;
ALTER TABLE `log_search` DROP PRIMARY KEY;
ALTER TABLE `replicache_client` DROP PRIMARY KEY;
ALTER TABLE `replicache_cvr` DROP PRIMARY KEY;
ALTER TABLE `resource` DROP PRIMARY KEY;
ALTER TABLE `slack_team` DROP PRIMARY KEY;
ALTER TABLE `stage` DROP PRIMARY KEY;
ALTER TABLE `stripe` DROP PRIMARY KEY;
ALTER TABLE `usage` DROP PRIMARY KEY;
ALTER TABLE `user` DROP PRIMARY KEY;
ALTER TABLE `warning` DROP PRIMARY KEY;
ALTER TABLE `workspace` DROP PRIMARY KEY;
ALTER TABLE `account` ADD PRIMARY KEY(`id`);
ALTER TABLE `app` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `aws_account` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `issue` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `issue_alert` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `issue_alert_limit` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `issue_count` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `issue_subscriber` ADD PRIMARY KEY(`workspace_id`,`stage_id`,`id`);
ALTER TABLE `lambda_payload` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `log_poller` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `log_search` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `replicache_client` ADD PRIMARY KEY(`id`);
ALTER TABLE `replicache_cvr` ADD PRIMARY KEY(`client_group_id`,`id`);
ALTER TABLE `resource` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `slack_team` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `stage` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `stripe` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `usage` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `user` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `warning` ADD PRIMARY KEY(`workspace_id`,`id`);
ALTER TABLE `workspace` ADD PRIMARY KEY(`id`);
70 replies
DTDrizzle Team
Created by thdxr on 9/9/2023 in #help
MySQL Blob
is there support for mysql blob type?
2 replies
DTDrizzle Team
Created by thdxr on 9/7/2023 in #help
push:mysql dropping unique index
i think drizzle generates the following when it needs to drop a unique index
ALTER TABLE `stage` DROP CONSTRAINT `name`;
ALTER TABLE `stage` DROP CONSTRAINT `name`;
this doesn't work - i think it should be
alter table `stage` drop key `name`
alter table `stage` drop key `name`
6 replies
DTDrizzle Team
Created by thdxr on 9/6/2023 in #help
postgres push issue
have a table like this
export const orgUserInfo = pgTable(
"org_user_info",
{
data: jsonb("data"),
orgId: text("org_id").notNull(),
userId: text("user_id").notNull(),
},
(table) => ({
primary: primaryKey(table.userId, table.orgId),
})
)
export const orgUserInfo = pgTable(
"org_user_info",
{
data: jsonb("data"),
orgId: text("org_id").notNull(),
userId: text("user_id").notNull(),
},
(table) => ({
primary: primaryKey(table.userId, table.orgId),
})
)
db push wants to do this
ALTER TABLE "org_user_info" DROP CONSTRAINT "org_user_info_pkey";
ALTER TABLE "org_user_info" ADD PRIMARY KEY ("user_id");
ALTER TABLE "org_user_info" DROP CONSTRAINT "org_user_info_pkey";
ALTER TABLE "org_user_info" ADD PRIMARY KEY ("user_id");
27 replies
DTDrizzle Team
Created by thdxr on 8/15/2023 in #help
drizzle push and primary key order
right now the primary key order isn't respected at least on MySQL work around is i just fix it manually using alter table statements but all my coworkers have to do this also - ideally this can be respected
5 replies
DTDrizzle Team
Created by thdxr on 7/20/2023 in #help
Dropping Primary Key
still having some issues where push is trying to drop my primary keys
ALTER TABLE `account` DROP PRIMARY KEY
ALTER TABLE `replicache_cvr` DROP PRIMARY KEY
ALTER TABLE `workspace` DROP PRIMARY KEY
ALTER TABLE `account` ADD PRIMARY KEY(`id`);
ALTER TABLE `replicache_cvr` ADD PRIMARY KEY(`id`);
ALTER TABLE `workspace` ADD PRIMARY KEY(`id`);
ALTER TABLE `account` DROP PRIMARY KEY
ALTER TABLE `replicache_cvr` DROP PRIMARY KEY
ALTER TABLE `workspace` DROP PRIMARY KEY
ALTER TABLE `account` ADD PRIMARY KEY(`id`);
ALTER TABLE `replicache_cvr` ADD PRIMARY KEY(`id`);
ALTER TABLE `workspace` ADD PRIMARY KEY(`id`);
38 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
support fsp for .onUpdateNow(),
title explains it
2 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
You're about to add not-null version without default value
I added this column
version: int("version").notNull().default(0),
version: int("version").notNull().default(0),
and it's trying to truncate because it thinks there's on default value
5 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
Cannot read properties of undefined (reading 'columns')
/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:11810
result[key].columns[value[0]].primaryKey = true;
^

TypeError: Cannot read properties of undefined (reading 'columns')
at fromDatabase (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:11810:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async mysqlPushIntrospect (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:37573:19)
at async Command.<anonymous> (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:52680:31)
/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:11810
result[key].columns[value[0]].primaryKey = true;
^

TypeError: Cannot read properties of undefined (reading 'columns')
at fromDatabase (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:11810:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async mysqlPushIntrospect (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:37573:19)
at async Command.<anonymous> (/home/thdxr/dev/projects/bumi/bumi/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:52680:31)
32 replies
DTDrizzle Team
Created by thdxr on 7/12/2023 in #help
0.27.2 mysql:push
mysql:push in 0.27.2 is trying to alter my primaryKey with no schema changes. it also seems to try and drop a constraint that doesn't exist yet? I think it's something to do with the unique index changes
26 replies
DTDrizzle Team
Created by thdxr on 6/16/2023 in #help
Timestamp as string
so when i have a timestamp in string mode, setting new Date().toISOString() does not work - i need to drop the trailing Z from it can drizzle handle this?
6 replies
DTDrizzle Team
Created by thdxr on 5/17/2023 in #help
type union on entire row
i can think of workarounds for this but figured i'd ask if i have a table that's like [id, type, data (json)] and i want a discriminated union based on type - is there a way to do this with drizzle? i was going to do my own fancy type stuff but though i'd ask first
4 replies
DTDrizzle Team
Created by thdxr on 4/17/2023 in #help
unrecognized_keys
Getting the following error when running generate:pg
ZodError: [
{
"code": "unrecognized_keys",
"keys": [
"primaryKey"
],
"path": [
"alteredTablesWithColumns",
0,
"altered",
1
],
"message": "Unrecognized key(s) in object: 'primaryKey'"
}
]
at handleResult (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:2317:24)
at ZodObject.safeParse (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:2410:16)
at ZodObject.parse (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:2390:29)
at applySnapshotsDiff (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:15064:44)
at prepareSQL (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:27032:20)
at prepareAndMigratePg (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:26884:48)
at Command2.<anonymous> (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:49563:9)
at Command2.listener [as _actionHandler] (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:827:21)
at /home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:1246:69
at Command2._chainOrCall (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:1178:16) {
ZodError: [
{
"code": "unrecognized_keys",
"keys": [
"primaryKey"
],
"path": [
"alteredTablesWithColumns",
0,
"altered",
1
],
"message": "Unrecognized key(s) in object: 'primaryKey'"
}
]
at handleResult (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:2317:24)
at ZodObject.safeParse (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:2410:16)
at ZodObject.parse (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:2390:29)
at applySnapshotsDiff (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:15064:44)
at prepareSQL (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:27032:20)
at prepareAndMigratePg (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:26884:48)
at Command2.<anonymous> (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:49563:9)
at Command2.listener [as _actionHandler] (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:827:21)
at /home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:1246:69
at Command2._chainOrCall (/home/thdxr/dev/projects/goodvisit/saguaro/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.js:1178:16) {
8 replies
DTDrizzle Team
Created by thdxr on 4/14/2023 in #help
how to do ANY
need to do where 'myvariable' = ANY(mycolumn)
8 replies
DTDrizzle Team
Created by thdxr on 4/4/2023 in #help
maximum call stack exceeded
Weird bug where whenever I add a where eq clause getting maximum call stack exceeded
59 replies