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

Deploy with Capistrano #14

Open
mattiassvedhem opened this issue Aug 24, 2011 · 6 comments
Open

Deploy with Capistrano #14

mattiassvedhem opened this issue Aug 24, 2011 · 6 comments

Comments

@mattiassvedhem
Copy link

So I'm easily able to go up with the migrations on Capistrano deploy.
I would like to implement going down on Capistrano rollback, how would you go about that?

Something like this, or is there any easier way?

On deploy, read from the db and save the belonging db version number in a file in the deployed directory.
Then on rollback, read from the file and take the db back to the right version.

@andreascreten
Copy link
Contributor

Sounds like the easiest way to do it indeed.

@ruckus
Copy link
Owner

ruckus commented Sep 28, 2011

When you say rollback do you mean that if during a deploy, the migrations complete but then the deploy fails after that, so you want to rollback any DB changes?

@ghost
Copy link

ghost commented Jan 8, 2013

yes, but also there is another case where the deploy succeeds, but you then want to roll it back anyway. In that case, you need to read the version from the schema.txt file of the OLD deploy. It is not currently written to the schema.txt so this would not be possible.

@salimane
Copy link
Collaborator

is this issue still valid ? if you want to rollback, you can do php ruckus.php db:migrate VERSION=-1 . Or may be I'm misunderstanding something
Thanks

@RichardBradley
Copy link

@salimane -- db:migrate VERSION=-1 isn't sufficient, as there is no guarantee that each Capistrano deploy added only one new migration to the live database. The feature request here seems to be for Capistrano to remember the schema version of each deploy, so that Capistrano "rollbacks" can integrate with ruckus.

@RichardBradley
Copy link

One way to implement this might be to add a new ruckus command which rolls back any migrations which are found in the schema_migrations table, but which do not have corresponding migrations in the codebase.
Say ruckus.php db:rollback_to_codebase

Then, in capistrano, after reverting the current link to the old codebase dir, you would cd into that version of the code and run the new rollback command.

( "you need to read the version from the schema.txt file of the OLD deploy" -- this approach would work in projects where the DB history is completely linear, but not on projects which have branches + merges. The version number is not sufficient to uniquely identify a DB version in those cases. )

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

5 participants