\MigrateTask
Task which allows you to do the following:
1. Run migrations (i.e. "up"). Example:
sake dev/tasks/MigrateTask up
2. Reverse previous migrations (i.e. "down"). Example:
sake dev/tasks/MigrateTask down
3. Make a new migration file for you with boilerplate code. Example:
sake dev/tasks/MigrateTask make:change_serialize_to_json
This generates a file like the following, containing the class "Migration_ChangeSerializeToJson":
YYYY_MM_DD_HHMMSS_change_serialize_to_json.php
IMPORTANT: This file will be automatically placed in your project directory in the path "<project>/code/migrations".
This can be overridden by defining an absolute path in the constant "MIGRATION_PATH" in your _ss_environment.php file.
Migration files that are automatically generated will be pseudo-namespaced with a "Migration_" prefix to help reduce
possible class name collisions.
- Author: Patrick Nelson, pat@catchyour.com
Synopsis
- // members
- protected string $title = 'Database Migrations (Module)';
- protected string $description = 'Performs atomic database migrations.';
- protected boolean $enabled = true;
- protected boolean $silent = false;
- protected boolean $error = false;
- protected boolean $shutdown = false;
- protected string $lastMigrationFile = '';
- // methods
- public void run()
- public void shutdown()
- public bool isEnabled()
- public void up()
- public void down()
- public void make()
- protected void output()
- public void setSilent()
- public static string getMigrationPath()
- public static array getAllMigrations()
- public static array getRunMigrations()
- public static int getLatestBatch()
Hierarchy
Extends
- BuildTask
Tasks
Line | Task |
---|---|
293 | SSv4: Move to YAML configuration instead. |
Members
protected
- $description
- $enabled
- $error
- $lastMigrationFile
- $shutdown
- $silent
- $title
Methods
protected
- output() — Output helper.
public
- down() — Reverses the most recent batch of migrations.
- getAllMigrations() — Returns an array of all possible migration classes that are currently on the filesystem.
- getLatestBatch() — Returns the number of the latest batch in the database.
- getMigrationPath() — Determines the path to store new migration files.
- getRunMigrations() — Returns all already run migrations or only the latest batch (if specified).
- isEnabled() — Ensure it's only visible in the CLI.
- make() — Generates a new migration.
- run()
- setSilent() — Squelches output.
- shutdown() — Will always execute after any/all migrations have run. The purpose of this is to clean up and to handle any unexpected errors which may occur.
- up() — Runs all currently outstanding migrations in a single batch, in order (by filename).