0

What is happening under the hood when executing this?

rails generate migration create_menu_categories_and_menu_items

Why can't I just create a file in the migrations directory? It seems I have to use the generate command in order for it to actually run, but the only file I see changed is the file created by the above command.

2 Answers 2

1

You can, but you need to get the time stamp at the beginning of the file name, so that rails can figure out that it's a "pending migration" and run it. It does this by storing the time stamp (or version in migration parlance) in a special database table (schema_migrations) and anything newer than the last run migration is pending.

Otherwise there's nothing special about the file itself

Sign up to request clarification or add additional context in comments.

Comments

1

You dont even have to create a separate migration file. You can just add a column to your table by adding the object to to your current migration class like this:

t.string :name

Then run a rake db:migrate

Hope this helps.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.