Class for database versioning.
Version - is integer started by 1.
VERSION.forward.sql:
- Plain SQL to execute for the version.
- Required: YES
VERSION.backward.sql:
- Plain SQL to rewind the version.
- Required: NO
- Currently not implemented.
VERSION.description.txt:
- Description text for the version.
- Required: YES
- Options Database/Structure/Options
Create the Structure object.
- options Database/Structure/Options - A options object.
Return: The created object.
Migrate the database to the given version or to the newest.
Currently only forward migration is supported.
- version Number - The version to migrate to.
Return: Nothing.
Close all used resources. (Database connections)
Return: Nothing.
Migration steps for the changelog table.
Replace "${tableName}" with your changelog table name in the sql query. Then run the query on your database.
ALTER TABLE `${tableName}`
CHANGE COLUMN `startedAt` `startedAt` DATETIME NOT NULL ,
CHANGE COLUMN `appliedAt` `appliedAt` DATETIME NULL DEFAULT NULL;
UPDATE `${tableName}` SET description = TRIM(TRIM("\n" FROM TRIM(description)));
ALTER TABLE `${tableName}` COMMENT = 'Holds the changes of the database structure.\nVersion: 2';