Omeka_Db_Migration_Manager

class Omeka_Db_Migration_Manager

Package: Db\Migration

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.

property _db
property _migrationsDir

Directory where migrations scripts are kept.

__construct(Omeka_Db $db, string $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’ optionand adds the ‘omeka_version’ option to the database.

Returns:void
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.

Returns:void
migrate(string $endTimestamp)

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.
Returns:

void

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 havenot yet been applied.

Returns:void
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(Omeka_Db|null $db)

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(DateTime $stopAt)

Migrate upwards to a specific timestamp.

Parameters:
  • $stopAt (DateTime) –
Returns:

void

_loadMigration(string $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(string $time)

Record the migration timestamp in the schema_migrations table.

Parameters:
  • $time (string) –
Returns:

void