Closed murjax closed 5 years ago
@tongueroo can i take this issue? Will open a PR if i can found a fix for it.
Handled by #346 Thanks to @peiyee
Note, the behavior that jets db:migrate
only migrates the development db but not the test db is consistent with rails db:migrate
. So only the development db will get migrated, not the test db.
Interestingly, the db:create
command creates databases for both the development and test. Guessing db:migrate
does not behave the same way as db:create
because you may still be working on migration code and it would be annoying to deal with cleaning up the accidentally migrated test db.
Anyway, @peiyee PR #346 addresses this by checking at the beginning of running specs whether or not the migrations have been ran on the test DB yet. If the test db does not have update to date migrations, it will exit and print an error.
Checklist
jets upgrade
command that makes this a simple task. There's also an Upgrading Guide: http://rubyonjets.com/docs/upgrading/My Environment
Expected Behaviour
When I create a migration and run
jets db:migrate
(no JETS_ENV or JETS_ENV_REMOTE specified), I expect the migration to be applied to the local development and test databases.Current Behavior
When I create a migration and run
jets db:migrate
(no JETS_ENV or JETS_ENV_REMOTE specified), the migration is applied to the local development database only.Step-by-step reproduction instructions
Create a demo application:
jets new demo
cd demo
.jets generate scaffold post title:string
jets db:create
.jets db:migrate
.Write a test that touches the
posts
table. I wrote a controller test for this example:Running this test, I get the following error:
Now I run the migration again specifying the test environment:
JETS_ENV=test jets db:migrate
.Upon running the test again, the test passes because the
posts
table now exists.Code Sample
Clone this sample application and follow the reproduction steps in the README.