Isaiah Smith
Isaiah Smith
DTDrizzle Team
Created by Isaiah Smith on 3/8/2024 in #help
Error thrown when running multiple migrations against turso database
Initially discussed over on the Turso Discord, we've run into an issue when trying to run drizzle-kit migrations against a turso database - https://discord.com/channels/933071162680958986/1214468598001700914 I've created a scoped down repo to reproduce the error but would love any help to try and triage where the error is coming from - https://github.com/IsaiahByDayah/turso-drizzle-migration/tree/main The issue happening is that we've generated migration files with drizzle-kit, but when we try to run those migrations against the remote databse we get the following error (full error attached):
LibsqlError: SQLITE_UNKNOWN: SQLite error: cannot rollback - no transaction is active
LibsqlError: SQLITE_UNKNOWN: SQLite error: cannot rollback - no transaction is active
If these same migrations are instead ran 1 at a time though, they both work as expected creating the tables, indexes, and row entries Im pretty stumped and also not very experienced with sql/databases so any and al help is appreciated
1 replies
DTDrizzle Team
Created by Isaiah Smith on 1/6/2024 in #help
Help understanding "--> statement-breakpoint"
Sorry for maybe such a "beginner" question, but im pretty new to database management and have a question around an "issue" im running in to trying to create migrations for my project w/ drizzle So looking at the docs (https://orm.drizzle.team/kit-docs/conf#sql-breakpoints), I see that drizzle will automatically insert these comment breakpoints into any generated migration files as some dialects (sqlite/libsql/turso in my case) needs them in order to have multiple DDL statements (https://www.javatpoint.com/ddl-commands-in-sql) in the same migration file. Cool. This (somewhat) makes sense and so far things seem to work just fine. The issue im running into is creating a "custom" migration file, and doing some INSERT commands. If I try to run the following, instead of seeing both rows added to the table, only 1 will be:
-- Custom SQL migration file, put you code below! --

INSERT INTO `some_table` VALUES (1, "foo");
INSERT INTO `some_table` VALUES (2, "bar");
-- Custom SQL migration file, put you code below! --

INSERT INTO `some_table` VALUES (1, "foo");
INSERT INTO `some_table` VALUES (2, "bar");
However if I add the breakpoint comment like the generated migrations, both entries get added when I run the migration:
-- Custom SQL migration file, put you code below! --

INSERT INTO `some_table` VALUES (1, "foo");--> statement-breakpoint
INSERT INTO `some_table` VALUES (2, "bar");
-- Custom SQL migration file, put you code below! --

INSERT INTO `some_table` VALUES (1, "foo");--> statement-breakpoint
INSERT INTO `some_table` VALUES (2, "bar");
It was my understanding that these breakpoints are only needed for DDL commands, but im trying to do DML commands (https://www.javatpoint.com/dml-commands-in-sql). Is this a bug or am I just misunderstanding some fundamental part since im still pretty new to all this? Also, is there something special about --> statement-breakpoint? Like, I tried googling that to get more info on what it does but nothing really came up. Is it a special "drizzle" string? Hopefully my questions makes sense. It took me forever to realize why I kept getting errors and running into problems so maybe this will help others as well.
4 replies