Open jkrumm opened 9 months ago
Encountering the same issue with Planetscale db:push
Same, have to manually do the necessary migrations every time.
Same.
Schema:
export const organization_memberships = mysqlTable('organization_memberships', {
userId: varchar('userId', {length: 36}).notNull(),
organizationId: varchar('organizationId', {length: 36}).notNull(),
role: tinyint('role', {unsigned: true}).default(ORG_ROLES_ID_MEMBER).notNull(),
}, (table) => ({
pk: primaryKey({columns: [table.organizationId, table.userId]}),
}));
Always results in
Warning Found data-loss statements:
· You're about to change role column type from tinyint to tinyint unsigned with 2 items
drizzle-kit: v0.20.6 drizzle-orm: v0.29.1
😿
FYI: Still present in drizzle-kit v0.20.7 even though other similar-ish issues were fixed
FYI: Still present in drizzle-kit v0.20.7 even though other similar-ish issues were fixed
From my understanding the drizzle-kit package is doing the migrations but I can be mistaken in thinking that the version of drizzle-orm doesn't play a part
FYI: Still present in latest release
drizzle-kit@0.20.8 drizzle-orm@0.29.2
@AndriiSherman @AlexBlokh @filipsobol
Could you guys please look into? It really seems like a bug unfortunately
Issue still persists, drizzle-kit want's to ALTER lots of stuff without need.
Hello,
I am having the same problem with composite primary keys and also timestamp columns.
I didn't change my models, and this is the output after drizzle-kit push
:
ALTER TABLE `user_statuses` DROP PRIMARY KEY;
ALTER TABLE `messages` MODIFY COLUMN `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE `messages` MODIFY COLUMN `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE `messages` MODIFY COLUMN `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE `user_statuses` MODIFY COLUMN `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE `user_statuses` MODIFY COLUMN `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE `users` MODIFY COLUMN `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE `users` MODIFY COLUMN `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE `users` MODIFY COLUMN `updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP;
ALTER TABLE `user_statuses` ADD PRIMARY KEY(`user_id`,`talk_id`);
@AndriiSherman @AlexBlokh @filipsobol
Hi again, is this issue investigated ?
As the project is getting more and more tables, I get more of these SQL statements and it is now impossible to use drizzle-kit push
.
I can't really drop timestamp columns or composite primary keys, so the fix got to come from drizzle-kit... :(
After executing migrations drizzle wants to do parts again. Please help me this is probably a bug. It wants to drop primary keys and add them again and then again the timestamp defaults. The first migration works fine though and tables are persisted perfectly. Just that it doesn't get a proper diff when running again.
DB: MySQL / Planetscale
"drizzle-orm": "^0.29.1", "drizzle-kit": "^0.20.6",
my migration script:
drizzle.config.ts
schema.ts
The first migration:
Then without changing anything and running my migration script it wants to do: