Skip to content

Rollback the migration when creation fails #3

@lefred

Description

@lefred

When for any reason (SQL syntax for example) the migration creation fails, all the steps already done for that migration should be removed.

Ex:

  [root@devel ~]# ./online-migration.py create world sql1.sql "tables creations"
  ERROR : ("Query failed. 1064 (42000): You have an error in your SQL syntax; check the manual that
  corresponds to your MySQL server version for the right syntax to use near ') ENGINE=InnoDB 
   DEFAULT CHARSET=latin1' at line 1", 0) !

On the filesystem, the files xxxx-down.mig and xxxx-up.mig should be removed (xxxx-up.meta is not created when it fails).

The database record with status "running" should be removed too:

mysql> select * from migration_sys;
+----+-------+---------+---------------------+---------------------+---------+
| id | db    | version | start_date          | apply_date          | status  |
+----+-------+---------+---------------------+---------------------+---------+
|  1 | world |       0 | 2014-08-01 21:34:17 | 2014-08-01 21:34:17 | ok      |
|  2 | world |       1 | 2014-08-01 22:57:41 | 2014-08-01 22:57:41 | running |
+----+-------+---------+---------------------+---------------------+---------+

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions