Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip database migrations #18

Closed
sosedoff opened this issue Jun 20, 2012 · 11 comments
Closed

Skip database migrations #18

sosedoff opened this issue Jun 20, 2012 · 11 comments

Comments

@sosedoff
Copy link
Contributor

I thought it would be useful to skip database migration task if the database is up to date.

Could utilize rake db:version and save it as a file somewhere at shared/.schema_version.

Ideas?

@skojin
Copy link

skojin commented Jun 21, 2012

that's solve no problem, this task take same time as run empty rake db:migrate

@sosedoff
Copy link
Contributor Author

The workaround could be an arbitrary execution of rake db:version after migration and saving the result to .migration file. During the next deployment, right before the migration, it should check the latest file under db/migrate and compare it to the saved version. Thats what i meant in the first place.

This could save around 3 seconds per deploy, which it a lot in most cases.

@skojin
Copy link

skojin commented Jun 21, 2012

That work only in migration numbers sequenced, as in old rails. Now migration with old timestamp can be merged and migrated after more fresh migration. E.g. when some feature developed long time and merged into master. Rails have schema_versions table and check is each migration migrated.

@sosedoff
Copy link
Contributor Author

Well, any suggestions then ?

@skojin
Copy link

skojin commented Jun 21, 2012

Close this issue, leave work with migrations for rails. Now migrations even not most long task on deploy, assets packaging take more time.

@mikong
Copy link
Member

mikong commented Jun 30, 2012

If some improvements can save a few seconds here and there, it may be worth a look. Though in this case, migrations is a bit tricky. Even if we track the migrations independently from the database (say in a text file), there's still the danger that someone may run a migration manually at a server. Using mina should not prevent people from being able to do that.

I'm closing this for now. @sosedoff, @skojin, thanks for contributing to the project.

@mikong mikong closed this as completed Jun 30, 2012
@rstacruz
Copy link
Member

I think we can do this by checking the current deployed version's db/schema.rb and diffing it with the db/schema.rb to be deployed.

Reopening for discusisons :)

@rstacruz rstacruz reopened this Jul 12, 2012
@sosedoff
Copy link
Contributor Author

Good point, lets just do that.

@mikong
Copy link
Member

mikong commented Jul 12, 2012

For everyone's reference, let's take note that running rake db:migrate isn't exactly the same as checking schema.rb. If there's a new migration that somehow didn't update the schema.rb, then the behavior of running rake db:migrate vs checking schema.rb is different.

However...

If 99% of the cases commit their latest schema.rb (as everyone should!), then it's worth doing this for the benefit of most people. We'll still provide the classic rake db:migrate task in the form of rails:db_migrate:force, the same way we have rails:assets_precompile:force.

@sosedoff, @skojin, thanks for participating in the discussions :)

@rstacruz
Copy link
Member

Done in v0.1.3.pre1, feel free to scrutinize and test it.

@sosedoff
Copy link
Contributor Author

Great, will try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants