Error running `drizzle-kit push` after schema update

This is my first time using Drizzle. After making my first schema change, the generated SQL code contains errors.
DROP TABLE `__new_leads`;
CREATE TABLE `__new_leads` (
`id` text PRIMARY KEY NOT NULL,
`cpf` text,
`email` text,
`phone` text,
`date` text NOT NULL
);

INSERT INTO `__new_leads`("id", "cpf", "email", "phone", "date") SELECT "id", "cpf", "email", "phone", "date" FROM `leads`;
DROP TABLE `leads`;
ALTER TABLE `__new_leads` RENAME TO `leads`;
DROP TABLE `__new_leads`;
CREATE TABLE `__new_leads` (
`id` text PRIMARY KEY NOT NULL,
`cpf` text,
`email` text,
`phone` text,
`date` text NOT NULL
);

INSERT INTO `__new_leads`("id", "cpf", "email", "phone", "date") SELECT "id", "cpf", "email", "phone", "date" FROM `leads`;
DROP TABLE `leads`;
ALTER TABLE `__new_leads` RENAME TO `leads`;
The schema went from id, cpf, date to id, cpf, email, phone, date. It tries to query the leads column which does not exist in the previous table.
1 Reply
Lucas
LucasOP2mo ago
For now, I'm switching from push to generate and migrate. This way, I can edit the migration before pushing it to the server.

Did you find this page helpful?