yogthos / migratus

MIGRATE ALL THE THINGS!
642 stars 93 forks source link

Multiple statements not supported in SQLite init #167

Closed WorldsEndless closed 5 years ago

WorldsEndless commented 5 years ago

Essentially the same issue as #93. SQLite init file with:

DROP TABLE IF EXISTS tokens;
--;;
CREATE TABLE tokens (
...
);

Only executes the DROP line. No errors are thrown, no further information; it simply ignores the rest. Presence of --;; doesn't effect the results.

However, in a normal migration (outside init.sql), this works fine if you have --;; between commands.

Side question: why is init.sql handled differently than others, and what is it for, if not for creating (initializing) your tables? I note that it works great in postgres.

yogthos commented 5 years ago

The init script is meant to be run once for any specific schema initialization that's not part of the actual migrations. The reason it needs to be in a separate file is due to the fact that regular migration checks can't be done before the migrations table is created. There's more info in the implementation here if you're interested to see what's happening. You should be using the init script to run the actual migrations.

yogthos commented 5 years ago

Since it is the same issue as 93, I'm going to close this one.

WorldsEndless commented 5 years ago

Fair enough. I opened a seperate issue for documentation purposes, since the other issue explicitly mentioned MySQL and this was SQLite.

yogthos commented 5 years ago

Ah ok, I'll update the title for the other issue.