Tasks library
Part of Active Record
The database tasks behind the flux db:* console commands: migrating, rolling back,
inspecting the migration status and dumping or loading the schema file.
Summary
Functions
flux db:forward STEP=n).flux db:migrate VERSION=x).flux db:migrate:down VERSION=x).flux db:migrate:status).flux db:migrate:up VERSION=x).flux db:migrate:redo STEP=n or VERSION=x).flux db:rollback STEP=n).flux db:schema:dump).flux db:schema:load).flux db:version).Functions
Refreshes the models and regenerates the schema file once migrations have run.
Parameters
- executed List<ActiveRecord::MigrationProxy> migrations that were run
Returns
- List<ActiveRecord::MigrationProxy> the same list
Returns the migration context of the active schema, creating it if needed.
Returns
- ActiveRecord::MigrationContext
Runs the next pending migrations (flux db:forward STEP=n).
Parameters
- steps Number optional, defaults to
1
Returns
- List<ActiveRecord::MigrationProxy>
Records the migrations as run for a database whose newest migration version is stored under the 'version' key of the 'ar_metadata' table, with nothing in the 'ar_schema_migrations' table. Every migration file up to that version is considered run, the key is deleted, and the indexes and foreign keys of a schema file that holds a 'Structure' object are imported into the metadata.
Imports the metadata (indexes, references and primary keys) of a schema file that holds a 'Structure' object.
Parameters
- metadata Map
Runs the pending migrations, or migrates to a version (flux db:migrate VERSION=x).
Parameters
- version Number/String optional, defaults to
nil
Returns
- List<ActiveRecord::MigrationProxy> migrations that were run
Reverts a single migration (flux db:migrate:down VERSION=x).
Parameters
- version Number/String
Returns
- List<ActiveRecord::MigrationProxy>
Prints the status of every migration (flux db:migrate:status).
Runs a single migration (flux db:migrate:up VERSION=x).
Parameters
- version Number/String
Returns
- List<ActiveRecord::MigrationProxy>
Returns the names of the console tasks.
Returns
- List<String> sorted
Brings the database up to date when the server starts: installs the migrations of the packages and plugins, warns about versions that have been run but have no file anymore, loads the schema file into a fresh database and runs the pending migrations.
Returns
- List<ActiveRecord::MigrationProxy> migrations that were run
Reverts and re-runs migrations (flux db:migrate:redo STEP=n or VERSION=x).
Parameters
- steps Number optional, defaults to
1 - version Number/String optional, defaults to
nila single migration to redo
Returns
- List<ActiveRecord::MigrationProxy> migrations that were run again
Reverts the newest migrations (flux db:rollback STEP=n).
Parameters
- steps Number optional, defaults to
1
Returns
- List<ActiveRecord::MigrationProxy>
Runs a task by its console name, e.g. 'migrate:status', with the adapter in sync mode. Errors are printed instead of raised.
Parameters
- name String
- env Map optional, defaults to
nilKEY=VALUE arguments of the command, e.g. { VERSION = '2019...' }
Returns
- Boolean whether the task ran without an error
Writes the current schema into the schema file (flux db:schema:dump).
Returns
- String path of the file
Loads the schema file, which creates the tables it describes and records its version
and every older migration as run (flux db:schema:load).
Returns the path of the schema file, relative to the game folder.
Returns
- String e.g. 'gamemodes/reborn/db/schema.lua'
Checks whether the schema file holds a 'Structure' object (the one-argument form of ActiveRecord.Schema:define). Such a file cannot be loaded.
Returns
- Boolean
Prints the current schema version (flux db:version).