Sequel::Plugins::InlineMigrations::
Migrator class
Superclass | Sequel::Migrator |
Subclass of Sequel::Migrator that provides the logic for extracting and running migrations from the model classes themselves.
Constants
- DEFAULT_OPTS
Default options for .run and initialize.
Attributes
- baseclass R
The Class at the top of the hierarchy from which migrations will be fetched
- column R
The name of the column which will contain the names of applied migrations as a Symbol.
- dataset R
The migration table dataset (a Sequel::Dataset).
- db R
The database to which the migrator will apply its migrations; a Sequel::Database.
- table R
The name of the migration table as a Sequel::SQL::QualifiedIdentifier.
- target R
The name of the target migration to play up or down to as a String.
Public Class Methods
Create a new Migrator
that will organize migrations defined for baseclass
or any of its subclasses for the specified db
. See Sequel::Plugins::InlineMigrations::Migrator.run
for argument details.
Migrates the supplied db
(a Sequel::Database) using the migrations declared in the given baseclass
. The baseclass
is the class to gather migrations from; it and all of its concrete descendents will be considered.
The options
this method understands:
column |
The column in the table that stores the migration version. Defaults to |
current |
The current version of the database. If not given, it is retrieved from the database using the |
table |
The name of the migrations table. Defaults to |
target |
The target version to migrate to. If not given, migrates to the maximum version. |
Examples
# Assuming Acme::Model is a Sequel::Model subclass, and Acme::Vendor is a subclass # of that... Sequel::InlineMigrations::Migrator.run( Acme::Model ) Sequel::InlineMigrations::Migrator.run( Acme::Model, :target => 15, :current => 10 ) Sequel::InlineMigrations::Migrator.run( Acme::Vendor, :column => :app2_version) Sequel::InlineMigrations::Migrator.run( Acme::Vendor, :column => :app2_version, :table => :schema_info2 )
Public Instance Methods
Fetch an Array of all model classes which are descended from the migrating subclass, inclusive.
Returns any migration objects found in the migrating subclass or any of its descendents as an Array of Sequel::SimpleMigration objects, sorted by the migration name and the name of its migrating class.
Returns two Arrays of migrations, the first one containing those which have already been applied, and the second containing migrations which are pending. Migrations that have been marked as applied but are (no longer) defined by a model class will be ignored.
Apply all migrations to the database