elverly
elverly
DTDrizzle Team
Created by elverly on 5/15/2024 in #help
Duplicate statements after adding .unique()
Starting from a schema that is entirely synced, I add one .unique() constraint on one of my columns, then run drizzle-kit push and I get the following
Warning You are about to execute current statements:

ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);

❯ No, abort
Yes, I want to execute all statements
Warning You are about to execute current statements:

ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);

❯ No, abort
Yes, I want to execute all statements
This will throw InvalidArgument desc = Duplicate key name 'MailingList_email_unique' (errno 1061) (sqlstate 42000) when trying to execute the second statement, but it will at least add it. Now that the key exists, on subsequent calls (without changing anything) it will try to remove it and add it again!
DROP INDEX `MailingList_email_unique` ON ``.`MailingList`;
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
DROP INDEX `MailingList_email_unique` ON ``.`MailingList`;
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
ALTER TABLE `MailingList` ADD CONSTRAINT `MailingList_email_unique` UNIQUE(`email`);
I am using "drizzle-kit": "^0.21.1"and "drizzle-orm": "^0.30.10" and PlanetScale (MySQL). Any support would be greatly appreciated! Thank you.
2 replies
DTDrizzle Team
Created by elverly on 5/15/2024 in #help
TypeError: columnType.startsWith is not a function
I am using PlanetScale and am interested in using npx drizzle-kit push to prototype my schema. I am using the latest "drizzle-orm": "^0.29.4" and "drizzle-kit": "^0.21.2". I completely cleared my database and ran npx drizzle-kit push with no problem. However on subsequent calls (without changing anything), I consistently run into this error
>npx drizzle-kit push
drizzle-kit: v0.21.2
drizzle-orm: v0.30.10

No config path provided, using default path
Reading config file 'C:\Users\sarah\Documents\GitHub\salesbop\drizzle.config.ts'
Warning: You need to pass an instance of Client:

import { Client } from "@planetscale/database";

const client = new Client({
host: process.env["DATABASE_HOST"],
username: process.env["DATABASE_USERNAME"],
password: process.env["DATABASE_PASSWORD"],
});

const db = drizzle(client);

Starting from version 0.30.0, you will encounter an error if you attempt to use anything other than a Client instance.
Please make the necessary changes now to prevent any runtime errors in the future

TypeError: columnType.startsWith is not a function
at fromDatabase (\node_modules\drizzle-kit\bin.cjs:15217:24)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async mysqlPushIntrospect (\node_modules\drizzle-kit\bin.cjs:106130:19)
at async mysqlPush (\node_modules\drizzle-kit\bin.cjs:106560:35)
at async Command.<anonymous> (\node_modules\drizzle-kit\bin.cjs:113617:7)
>npx drizzle-kit push
drizzle-kit: v0.21.2
drizzle-orm: v0.30.10

No config path provided, using default path
Reading config file 'C:\Users\sarah\Documents\GitHub\salesbop\drizzle.config.ts'
Warning: You need to pass an instance of Client:

import { Client } from "@planetscale/database";

const client = new Client({
host: process.env["DATABASE_HOST"],
username: process.env["DATABASE_USERNAME"],
password: process.env["DATABASE_PASSWORD"],
});

const db = drizzle(client);

Starting from version 0.30.0, you will encounter an error if you attempt to use anything other than a Client instance.
Please make the necessary changes now to prevent any runtime errors in the future

TypeError: columnType.startsWith is not a function
at fromDatabase (\node_modules\drizzle-kit\bin.cjs:15217:24)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async mysqlPushIntrospect (\node_modules\drizzle-kit\bin.cjs:106130:19)
at async mysqlPush (\node_modules\drizzle-kit\bin.cjs:106560:35)
at async Command.<anonymous> (\node_modules\drizzle-kit\bin.cjs:113617:7)
There seems to be a type error that occurs during Introspection. PS. I am passing an instance of the planetscale Client, so I am also confused as to why I am getting this warning. Any support would be greatly appreciated! Thank you!
3 replies