Runs a list of migrations in one direction. A migrator is created by ActiveRecord::MigrationContext with the direction ('up' or 'down'), the migrations that exist and an optional target version. It works out which of them have to run by comparing them with the versions stored by ActiveRecord::SchemaMigration, and runs each one inside of a transaction if the database supports it, storing or forgetting its version afterward. A migration that fails is rolled back and cancels the ones after it.

This file also loads the other parts of the migrations system.

Summary

Methods

Returns the migration of the newest version that has been run.
Returns the newest version that has been run.
down()shared
Checks whether the migrator migrates down.
Runs a migration in the direction of the migrator, inside of a transaction if the database supports it.
Creates a migrator, which runs a list of migrations in one direction.
Checks whether a target version was given that no migration has.
migrate()shared
Runs every runnable migration.
Returns the versions of the migrations that have been run, as a set.
Returns the migrations that have not been run yet, oldest first.
Checks whether a migration has been run.
Records that a migration was run, or that it was reverted.
run()shared
Runs only the migration of the target version.
Returns the migrations that #migrate runs: going up, the pending migrations up to the target; going down, the migrations that have been run, from the current one down to (but not including) the target.
target()shared
Returns the migration of the target version.
up()shared
Checks whether the migrator migrates up.

Methods

ActiveRecord.Migrator:current_migration()

shared packages/active_record/lib/migrator/migrator.lua:87

Returns the migration of the newest version that has been run.

Returns

  • ActiveRecord::MigrationProxy or nil

ActiveRecord.Migrator:current_version()

shared packages/active_record/lib/migrator/migrator.lua:75

Returns the newest version that has been run.

Returns

  • Number 0 if no migration has been run

ActiveRecord.Migrator:down()

shared packages/active_record/lib/migrator/migrator.lua:48

Checks whether the migrator migrates down.

Returns

  • Boolean

ActiveRecord.Migrator:execute_migration_in_transaction(migration)

shared packages/active_record/lib/migrator/migrator.lua:214

Runs a migration in the direction of the migrator, inside of a transaction if the database supports it. Records the version as run (or forgets it) afterward. A failed migration is rolled back and raises an error, so that no later migration runs. Foreign keys are not enforced while the migration runs on a database that rebuilds tables to change them, as SQLite does; they are checked before the migration is committed, and a row that the migration has made break one fails it.

Parameters

  • migration ActiveRecord::MigrationProxy

Returns

  • Boolean whether the migration was run; false if it had been run (or reverted) already

ActiveRecord.Migrator:init(direction, migrations, target_version)

shared packages/active_record/lib/migrator/migrator.lua:26

Creates a migrator, which runs a list of migrations in one direction. Normally created by ActiveRecord::MigrationContext.

Parameters

  • direction String 'up' or 'down'
  • migrations List<ActiveRecord::MigrationProxy> sorted by version
  • target_version Number optional, defaults to nil version to migrate to

Returns

  • ActiveRecord::Migrator(self)

ActiveRecord.Migrator:invalid_target()

shared packages/active_record/lib/migrator/migrator.lua:107

Checks whether a target version was given that no migration has.

Returns

  • Boolean

ActiveRecord.Migrator:migrate()

shared packages/active_record/lib/migrator/migrator.lua:173

Runs every runnable migration.

Returns

  • List<ActiveRecord::MigrationProxy> migrations that were run

ActiveRecord.Migrator:migrated()

shared packages/active_record/lib/migrator/migrator.lua:54

Returns the versions of the migrations that have been run, as a set.

Returns

  • Map version to true

ActiveRecord.Migrator:pending_migrations()

shared packages/active_record/lib/migrator/migrator.lua:113

Returns the migrations that have not been run yet, oldest first.

Returns

  • List<ActiveRecord::MigrationProxy>

ActiveRecord.Migrator:ran(migration)

shared packages/active_record/lib/migrator/migrator.lua:69

Checks whether a migration has been run.

Parameters

  • migration ActiveRecord::MigrationProxy

Returns

  • Boolean

ActiveRecord.Migrator:record_version_state_after_migrating(version)

shared packages/active_record/lib/migrator/migrator.lua:286

Records that a migration was run, or that it was reverted.

Parameters

  • version Number

ActiveRecord.Migrator:run()

shared packages/active_record/lib/migrator/migrator.lua:191

Runs only the migration of the target version.

Returns

  • List<ActiveRecord::MigrationProxy> the migration, if it was run

ActiveRecord.Migrator:runnable()

shared packages/active_record/lib/migrator/migrator.lua:133

Returns the migrations that #migrate runs: going up, the pending migrations up to the target; going down, the migrations that have been run, from the current one down to (but not including) the target.

Returns

  • List<ActiveRecord::MigrationProxy>

ActiveRecord.Migrator:target()

shared packages/active_record/lib/migrator/migrator.lua:97

Returns the migration of the target version.

Returns

  • ActiveRecord::MigrationProxy or nil

ActiveRecord.Migrator:up()

shared packages/active_record/lib/migrator/migrator.lua:42

Checks whether the migrator migrates up.

Returns

  • Boolean

Defined in