Reputation: 1
I'm new to rails, and I accidentally ran rails db:rollback
command in a development.
Next I did rails db:migrate:up VERSION=XXXX
to change status of the file I rolled back from down to up.
The migration file was about images. However my images were gone in a development mode due to rollback, files status the same as before I ran rails db:rollback
.
In this case, if I pushed this to remote repository, and it's merged in production, the images already there will be gone as well as mine in development?
Upvotes: 0
Views: 241
Reputation: 5552
When add_column
method in migration is run you just add column in migration so it will run for production & development environment. Now you added images through localhost to your application and stored in database. So those will be stored to database regardless migration.
Rollback will remove column running remove_column
so it will hamper your development as removing column will make you loose all data inside column of table. So on production it does not deal same.
Images are getting pushed to production database or remote repository, it is just to add or remove column only so rollback will affect only your local/development
Upvotes: 1
Reputation: 164669
Unless you're doing something wacky in your migrations, any goofs like this you make to your development database will not effect production. That's why dev and prod databases are separate.
The general problem of "is it safe to push to production" can be mitigated by adding a staging server which runs in the production Rails environment, but is used for additional manual testing of new features. Once everything checks out in staging then push to production. Many services provide a "pipeline" to do this for you, for example Heroku Pipelines.
Upvotes: 0