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

db_migrate not migrating #292

Closed
danhixon opened this issue Mar 20, 2015 · 4 comments
Closed

db_migrate not migrating #292

danhixon opened this issue Mar 20, 2015 · 4 comments

Comments

@danhixon
Copy link

I've added a migration but it doesn't run when I deploy. I try:

$ mina rails:db_migrate
-----> DB migrations unchanged; skipping DB migration

I tried:

force_migrate=true mina rails:db_migrate
-----> Migrating database
Could not locate Gemfile

I tried:

$ diff -r 264/db/migrate 265/db/migrate
Only in 265/db/migrate: 20150320184220_add_redirect_to_communication_types.rb

I'd love any ideas on what I can do to make this work? Thanks in advance! Mina is so good.

@d4be4st
Copy link
Member

d4be4st commented Mar 20, 2015

Your schema.db did not change between two deploys. That is how mina determines if it nees to run migrate or not.

rails:db_migrate is a task meant to be run inside deploy do as invoke :'rails:db_migrate'

you need to do this:

mina 'rake[db:migrate]' 

or change your schema.db

@danhixon
Copy link
Author

Thanks for the quick reply! That definitely worked and make my migration run. Any chance you help me so they'll run automatically? I thought that the migrations ran when the contents of db/migrate changed between deploys. See: https://github.com/mina-deploy/mina/blob/master/lib/mina/rails.rb#L143-L145

@d4be4st
Copy link
Member

d4be4st commented Mar 20, 2015

You need to add that inside your deploy script
there rails taksk are meant to be invoked inside deploy scripts as stated here: https://github.com/mina-deploy/mina/blob/master/lib/mina/rails.rb#L128

add something like this to your deploy.rb script:

desc "Deploys the current version to the server."
task :deploy => :environment do
  deploy do
    # Put things that will set up an empty directory into a fully set-up
    # instance of your project.
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    invoke :'deploy:cleanup'

    to :launch do
      queue "mkdir -p #{deploy_to}/#{current_path}/tmp/"
      queue "touch #{deploy_to}/#{current_path}/tmp/restart.txt"
    end
  end
end

@danhixon
Copy link
Author

I have that. It is working for me in another project I have but not this one. I'll figure it out eventually.

desc "Deploys the current version to the server."
task :deploy => :environment do
  deploy do
    # Put things that will set up an empty directory into a fully set-up
    # instance of your project.
    invoke :'git:clone'
    invoke :'deploy:link_shared_paths'
    invoke :'bundle:install'
    invoke :'rails:db_migrate'
    invoke :'rails:assets_precompile'
    to :launch do
      invoke :restart_services
    end
  end
end

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

2 participants