DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

How to handle an initial schema on database that had previously no migration scripts?

On our existing project our database had previously no migration scripts, therefore the following approach has been proposed:

  1. Consider the schema as is and from now on any change will be via a migration script.
  2. An initial migration with a hardcoded time prior to the ones created on (1.) will be developed, and run on non-production environment in order to initialize the database. This initial migration will be developed in a later time than the migrations developed on (1.).

The migration will be on a Laravel project as we migrate from codeigniter.

So I wonder if a similar situation had happened to you as well and how you handled it. The problem is once we develop the initial migration on (2.) what complication may have with existing ones using laravel migration mechanism?

For me is uknown waters so I want your opinion in this approach.

Top comments (2)

Collapse
 
pcmagas profile image
Dimitrios Desyllas

Was that your first migration developed and afterwards you develped any migration changing the DB schema or was developed after the schema changing migrations?

Note I do not mean when the migration will run but when a developer wrote code for it.

 
pcmagas profile image
Dimitrios Desyllas

I mean that did you created a migration from the dump first and then all other migrations or the opposite?