Open Bromles opened 1 month ago
The workaround (splitting drop statement) is unpleasant because it requires user to manually arrange all drop statements in correct order, otherwise an error is thrown (i.e. if BookAuthor
is a junction table, and you are trying to drop Book
or Author
tables before dropping BookAuthor
)
Description
When trying to roll back migration with drop statement which includes more than one table with SQLite, it fails with
Execution Error: error returned from database: (code: 1) near ",": syntax error
The same migrations work fine with PostgreSQL.
It seems like SQLite doesn't support dropping multiple tables in one statement. I think this should be either worked around by Sea ORM itself or mentioned in the official documentation in the Migration section
Steps to Reproduce
up
functiondown
functionExpected Behavior
All tables mentioned in drop statement are dropped
Actual Behavior
Migration roll back fails with syntax error
Reproduces How Often
At every attempt
Workarounds
Split drop statements so that they include only one table per statement
Reproducible Example
Cargo.toml of migration crate
migration file (i.e. m20220101_000001_create_table)
.env
lib.rs and main.rs are unchanged from
sea-orm-cli migrate init
The first drop statement with only
BookAuthor
table executes successfully, but the second one, which includes bothBook
andAuthor
tables, fails with SQLite while executing successfully with PostgreSQL.Error happens during execution of the following SQL statement:
\n\nDROP TABLE IF EXISTS \"book\",\n\"author\"\n
. Error message isExecution Error: error returned from database: (code: 1) near ",": syntax error
, which is not really informative without debug output which logs statementsVersions
Tried with
sea-orm-migration
1.0.0-rc.7 and 0.12.15