1 /**
2 A library for automatically executing SQL DB migrations.
3 
4 Not tested!
5 */
6 module migrations.migration;
7 
8 import migrations.models;
9 
10 void migrate(Migrations m, void delegate()[] changes) {
11     immutable version_ = m.version_;
12     if(changes.length > version_) {
13         auto transaction = m.db.getTransaction(m.db.getConnection());
14         foreach(change; changes[version_ .. $])
15             change();
16         m.version_ = cast(uint) changes.length;
17         transaction.commit();
18     }
19 }