Running drizzle-kit push:sqlite with Turso

Hi, I ran into an issue today trying to update my schema on Turso using drizzle and Sqlite. I'm running the command: drizzle-kit push:sqlite I then get this error: LibsqlError: SQLITE_UNKNOWN: SQLite error: table isak.dev_burger has 11 columns but 10 values were supplied I was like, okey I need to check how to solve this. But the main issue here is that this command deletes all my data. Does anyone know why that happens? Thanks!
Solution:
So it seems like drizzle did not generate correct sql (from my knowledge). I ended up writing this to insert data only into the columns that existed before `` ALTER TABLE isak.dev_burger RENAME TO isak.dev_burger_old`;--> statement-breakpoint ...
Jump to solution
1 Reply
Solution
WiESA
WiESA6mo ago
So it seems like drizzle did not generate correct sql (from my knowledge). I ended up writing this to insert data only into the columns that existed before
ALTER TABLE `isak.dev_burger` RENAME TO `isak.dev_burger_old`;--> statement-breakpoint

CREATE TABLE `isak.dev_burger` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`resturant_name` text(256),
`created_at` integer DEFAULT CURRENT_TIMESTAMP,
`updatedAt` integer,
`rating` integer,
`description` text,
`city` text,
`country` text(256),
`tested_food` text,
`images` text,
`address` text DEFAULT 'empty address'
);--> statement-breakpoint

INSERT INTO `isak.dev_burger` (id,
resturant_name,
created_at,
updatedAt,
rating,
description,
city,
country,
tested_food,
images)
SELECT * FROM `isak.dev_burger_old`;--> statement-breakpoint

DROP TABLE `isak.dev_burger_old`;--> statement-breakpoint
ALTER TABLE `isak.dev_burger` RENAME TO `isak.dev_burger_old`;--> statement-breakpoint

CREATE TABLE `isak.dev_burger` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`resturant_name` text(256),
`created_at` integer DEFAULT CURRENT_TIMESTAMP,
`updatedAt` integer,
`rating` integer,
`description` text,
`city` text,
`country` text(256),
`tested_food` text,
`images` text,
`address` text DEFAULT 'empty address'
);--> statement-breakpoint

INSERT INTO `isak.dev_burger` (id,
resturant_name,
created_at,
updatedAt,
rating,
description,
city,
country,
tested_food,
images)
SELECT * FROM `isak.dev_burger_old`;--> statement-breakpoint

DROP TABLE `isak.dev_burger_old`;--> statement-breakpoint
Want results from more Discord servers?
Add your server