0

If I generate a migration-file, for example rails generate migration create_articles title description:text, then I have to do an additional rails db:migrate afterward.

Theoretically it could all be done with one terminal-command as well: Create table articles field:type ...

Why is the process of creating a database-table done in two steps?

What's the benefit of the two-steps approach?

2
  • 2
    To have more control over the process. Imagine you misspelled or forgot a column then you can add it to your migration file before migrating. Commented Sep 26, 2020 at 6:21
  • 1
    @ErwinSchens Makes sense. Thanks. Grüsse aus dem Saarland. Commented Sep 26, 2020 at 7:05

1 Answer 1

1
  1. You can edit the migration files before running a migration.

  2. Every migration file has a timestamp. If you are working in a team and create a branch, your migrations are in your branch at first. If you deploy your branch your migration files will be deployed aswell. Because the migration files are independent from a database, you can track what happend to the tables and also update your local database to be up to date.

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

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.