Omeka_Db_Migration_Manager

Package: Db\Migration

class Omeka_Db_Migration_Manager

Manages database migrations (both upgrades and downgrades).

constant MIGRATION_TABLE_NAME

Name of the migrations table.

constant MIGRATION_DATE_FORMAT

Formatting string to convert dates into YYYYMMDDHHMMSS pattern.

constant ORIG_MIGRATION_OPTION_NAME

Name of the original database option storing the integer migration number.

constant VERSION_OPTION_NAME

Name of the new database option storing the core software version number.

__construct(Omeka_Db $db, $migrationsDir)
Parameters:
  • $db (Omeka_Db) –
  • $migrationsDir (string) –
setupTimestampMigrations()

Set up Omeka to use timestamped database migrations.

This creates the ‘schema_migrations’ table, drops the ‘migration’ option and adds the ‘omeka_version’ option to the database.

markAllAsMigrated()

Mark all of the migrations as having been run. Used by the installer as a way of indicating that the database is entirely up to date.

migrate($endTimestamp = null)

Migrate the database schema.

Parameters:
  • $endTimestamp (string) – (optional) Timestamp corresponding to the stop point for the migration. If older than the current time, database will migrate down to that point. If newer, the opposite. Defaults to the current timestamp.
canUpgrade()

Determine whether or not it is possible to migrate the Omeka database up.

This is based entirely on whether there exist any migrations that have not yet been applied.

dbNeedsUpgrade()

Determine whether the database must be upgraded.

In order to return true, this requires that canUprade() == true, and also that Omeka’s code has recently been upgraded.

finalizeDbUpgrade()

Finalize the database upgrade by setting the most up-to-date version of Omeka.

getDefault($db = null)

Return the default configuration of the database migration manager.

Parameters:
  • $db (Omeka_Db|null) –
Returns:

Omeka_Db_Migration_Manager

_getAllMigratedVersions()

Retrieve all the versions that have been migrated.

Returns:array
_getMigrationTableName()

Return the name of the table associated with schema migrations.

Returns:string
_getMigrationFileList()

Return a list of migration files in the migration directory.

Returns:array An associative array where key = timestamp of migration, value = full filename of the migration.
_migrateUp($stopAt)

Migrate upwards to a specific timestamp.

Parameters:
  • $stopAt (DateTime) –
_loadMigration($filename)

Require the migration file and return an instance of the class associated with it.

Parameters:
  • $filename (string) – Migration script filename.
Returns:

Omeka_Db_Migration_AbstractMigration

_getPendingMigrations(DateTime $until)

Retrieve a list of all migrations that have not been run yet, ending at the latest time given by $until.

Parameters:
  • $until (DateTime) –
Returns:

array

_recordMigration($time)

Record the migration timestamp in the schema_migrations table.

Parameters:
  • $time (string) –