Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip database migration while deploying Rails application using Capistrano 3

When we run cap deploy, it runs all the migrations during deployment. We have to point the application to existing DB and don't want modify existing DB.

Can anybody suggest how can we skip the migration step while deploying the application?

like image 538
Amit Patel Avatar asked Feb 03 '15 13:02

Amit Patel


People also ask

Why do we need migration in Rails?

A Rails migration is a tool for changing an application's database schema. Instead of managing SQL scripts, you define database changes in a domain-specific language (DSL). The code is database-independent, so you can easily move your app to a new platform.

How does Rails know which migration to run?

Internally Rails only uses the migration's number (the timestamp) to identify them. Prior to Rails 2.1 the migration number started at 1 and was incremented each time a migration was generated. With multiple developers it was easy for these to clash requiring you to rollback migrations and renumber them.

Do Rails migrations run in transaction?

On databases that support transactions with statements that change the schema, migrations are wrapped in a transaction. If the database does not support this then when a migration fails the parts of it that succeeded will not be rolled back. You will have to rollback the changes that were made by hand.

What is Capistrano used for?

Capistrano is an open-source tool for running scripts on multiple servers; its main use is deploying web applications.


1 Answers

I suppose you are using capistrano/rails.

According to the doc, you can require just what you need manually:

# Capfile
require 'capistrano/bundler' 
require 'capistrano/rails/assets'
# require 'capistrano/rails/migrations'
like image 174
scorix Avatar answered Sep 26 '22 06:09

scorix