0

For a Rails project, if you are given a DB dump, what's gong to be the way?

  1. I run all the migrations, and then I load the DB dump.
  2. I load just the DB dump.

In point 2, if I load just the DB dump, and I, then add a new migration to my project. So then, running rake db:migrate will only run the new migration, since the old migrations have already been run by loading DB dump.

Or, loading a DB dump will have nothing to do with running migrations. A migration will only be marked up if you have run rake db:migrate?

Note: The DB dumb isn't Rails schema, it has been generated by MySQL, and it contains all the data a fellow developer has.

Arslan Ali
  • 17,418
  • 8
  • 58
  • 76
  • 1
    I was just going to upvote this question, and suddenly, I saw my name; felt proud, and felt a little shame. – Arslan Ali Dec 11 '16 at 03:13

1 Answers1

2

I would first load the db dump, as it also contains all you data and the current schema structure.

running rake db:migrate will only run the new migration

This depends. If your db dump has a schema_migrations table, that lists all the previously applied migrations, it will not apply the migrations. Otherwise, it will try to and fail.

You basically need these steps:

  1. Import your dump
  2. Create a Rails schema (rake db:schema:dump)
  3. If you have newer migrations, run them
born4new
  • 1,677
  • 12
  • 12
  • I've a dumb file of 10 GB, and now I'm unable to know that either that file contains `schema_migrations` table or not. File is too huge to be read. Any solution for that? – Arslan Ali Apr 07 '16 at 06:21
  • 1
    If you got it from a Rails app, chances are there will be one (unless people wanted their life complicated and did not want to use db migrations). If not, don't bother searching, it's not there :). – born4new Apr 07 '16 at 06:22