How to generate Rails migration with Docker

Viewed 3058

I'm trying to generate a migration for my Rails 4 project running within Docker.

What I've tried so far is

docker-compose run web rails g migration migration_name
docker-compose exec web rails g migration migration_name

Terminal keeps saying me that everything is ok, the migration was successfully created and all. But i don't see migration file in my project.

However if I check the project files in Docker

docker-compose exec web bash
ls -l db/migrate/

I see that the file is actually there.

I'm on Mac OS X if it could help

2 Answers

You should look into making your root app directory a volume on your host machine. Documentation on volumes.

In your docker-compose.yml, you can add your root volume using:

volumes:
  - .:/YOUR-APP-NAME

When mounting properly it still took a minute or two to show up in my IDE

Related