A
A
Astrohas2018-01-30 22:45:35
MySQL
Astrohas, 2018-01-30 22:45:35

How to create a table migration based on another table?

So there is a table Foo. And there is a table FooNew - which has evolved from Foo (a couple of fields have been added, field types have changed). We need to get ALter's SQL code that can make the Foo structure the same as FooNew. Is there something similar?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Fedorov, 2018-01-31
@Astrohas

OPTIONS:

  1. Already suggested: How to synchronize only the structure of the database?
  2. One-time write an ALTER query by hand
  3. Use migrations
    - in the first migration, load a dump with the structure of the existing Foo through a file that will lie, for example, with migrations
    - manually describe migrations that update the table
    - and then work like white people
    From myself - I recently came to the project, the first programmer worked the old fashioned way and the problem with migrations arose immediately in the first hour. We made a dump of the structure, uploaded it to a file and pulled it up in the first migration, then created migrations already ... followed by GIT

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question