How to conditionally apply migrations? #3676
Unanswered
raif-s-naffah
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
hi there,
i recently added a new feature to my (Rocket) web app which uses sqlx 0.8.3.
the web app now can run in 2 different modes. which one is used, incl. when running tests, is selected on the command line through an environment variable. so to run the tests in mode
B
i do:i also have a
migrations
folder at the top of the project's tree where 3 migration.sql
files already exist.to test one of the modes, i need to run a migration that inserts few rows in a table. i added that migration in a new sub-directory under
migrations
and now i have the following tree structure:i also have a mock DB that i inject when running the tests. during the initialization of the server, the mock DB constructor has code like this...
i thought if i added an
if
w/ a similar block to the above using./migrations/test
as the source i would have a way of conditionally migrating the mock DB based on the mode but i'm getting an error like this:the number referenced in
VersionMissing
is in fact the integer part of M1 migration sql file, which looks like a timestamp —btw. all migrations were "added" using the defaultsqlx migrate add xxx
form.would appreciate it if you can tell me if it's possible to selectively and conditionally apply a set of migrations from different folders w/o duplicating common .sql migration files? if yes, how?
thanks in anticipation + cheers;
rsn
Beta Was this translation helpful? Give feedback.
All reactions