Issue with push command
Hello. I pushed migrations to database using
drizzle-kit push:mysql
and It worked fine. Running it again gave me error. (check image)
My Table:
export const linksVisitor = mysqlTable(
"links_visitor",
{
linkId: varchar("link_id", { length: 24 }).references(() => links.id, {
onDelete: "cascade",
}),
viewedAt: timestamp("viewed_at").defaultNow(),
linkCreator: varchar("link_creator", { length: 255 })
.references(() => user.id, { onDelete: "cascade" })
.notNull(),
ip: varchar("ip", { length: 20 }).notNull(),
},
(self) => ({
pk: primaryKey({
columns: [self.linkId, self.ip],
}),
})
);
export const linksVisitor = mysqlTable(
"links_visitor",
{
linkId: varchar("link_id", { length: 24 }).references(() => links.id, {
onDelete: "cascade",
}),
viewedAt: timestamp("viewed_at").defaultNow(),
linkCreator: varchar("link_creator", { length: 255 })
.references(() => user.id, { onDelete: "cascade" })
.notNull(),
ip: varchar("ip", { length: 20 }).notNull(),
},
(self) => ({
pk: primaryKey({
columns: [self.linkId, self.ip],
}),
})
);
![No description](https://answer-overflow-discord-attachments.s3.amazonaws.com/1224725405252976720/Screenshot_2024-04-02_at_7.50.46_PM.png)
1 Reply
Some verbose output:
Warning You are about to execute current statements:
ALTER TABLE `links_visitor` DROP PRIMARY KEY;
ALTER TABLE `links` MODIFY COLUMN `created_at` timestamp DEFAULT (now());
ALTER TABLE `links_visitor` MODIFY COLUMN `viewed_at` timestamp DEFAULT (now());
ALTER TABLE `user` MODIFY COLUMN `created_at` timestamp DEFAULT (now());
ALTER TABLE `links_visitor` ADD PRIMARY KEY(`link_id`,`ip`);
Warning You are about to execute current statements:
ALTER TABLE `links_visitor` DROP PRIMARY KEY;
ALTER TABLE `links` MODIFY COLUMN `created_at` timestamp DEFAULT (now());
ALTER TABLE `links_visitor` MODIFY COLUMN `viewed_at` timestamp DEFAULT (now());
ALTER TABLE `user` MODIFY COLUMN `created_at` timestamp DEFAULT (now());
ALTER TABLE `links_visitor` ADD PRIMARY KEY(`link_id`,`ip`);