byjg / php-migration

Simple library writen in PHP without framework dependancy for database version control. Supports Sqlite, MySql, Sql Server and Postgres
MIT License
155 stars 27 forks source link

Is there a way to set initial schema version? #35

Open cthu1hoo opened 3 years ago

cthu1hoo commented 3 years ago

i.e. assume that base schema corresponds to version X instead of "0". otherwise i'm not sure how should this be integrated with an application that has extant migrations.

my thought was to create migrations record table filled with initial data in the base schema but it seems hackish somehow.

a few additional thoughts:

therefore, i normally keep base schema at latest version and support migrations from older installed schemas as needed.

thanks for any advice.

byjg commented 3 years ago

Hello, it is possible to have a base from different versions. Basically, the system uses the base.sql here and we start from "0" here.

So, it means, if we manage getBaseSql() to get a base.sql file in the format "base-nnnnn.sql" (where nnnnn is the version) we can trick the system to start the migration from that version.