class Clear::Migration::Manager
- Clear::Migration::Manager
- Reference
- Object
Overview
The migration manager is a singleton, it load all the migrations,
check which one are #up
and #down
, and can trigger one or multiple
downgrade / upgrade of the database.
The migration system needs the creation of a table named __clear_metadatas
in your database. This table will be created automatically on the first
initialization of the Migration Manager.
Included Modules
Defined in:
clear/migration/manager.crConstant Summary
-
METADATA_VERSION =
"1"
-
Used to migrate between metadata version, in case we need it in the future.
Class Method Summary
-
.instance
To access to the manager
Clear::Migration::Manager.instance
Instance Method Summary
-
#apply_all
Apply all the migrations not yet applied.
- #apply_to(version, direction = :both)
-
#commited?(m : Clear::Migration)
Return
true
if the migration has been commited (already applied into the database) orfalse
otherwise - #current_version
-
#down(number : Int64) : Nil
Force down a migration; throw error if the mgiration is already down
-
#ensure_ready
Create if needed the metadata table to save the migrations.
-
#find(number)
Fetch the migration instance with the selected number
-
#load_existing_migrations
Fetch all the migrations already activated on the database.
- #max_version
- #migrations_up
-
#print_status : String
Print out the status ( up | down ) of all migrations found by the manager.
- #refresh
-
#reinit!
Force reloading the migration system Recheck all the current up migrations and the metadata table.
-
#up(number : Int64) : Nil
Force up a migration; throw error if the migration is already up
Instance methods inherited from module Clear::ErrorMessages
build_error_message(message : String, ways_to_resolve : Tuple | Array = Tuple.new, manual_pages : Tuple | Array = Tuple.new)
build_error_message,
converter_error(from, to)
converter_error,
format_width(x, w = 80)
format_width,
illegal_setter_access_to_undefined_column(name)
illegal_setter_access_to_undefined_column,
lack_of_primary_key(model_name)
lack_of_primary_key,
migration_already_down(number)
migration_already_down,
migration_already_up(number)
migration_already_up,
migration_drop_irreversible(name)
migration_drop_irreversible,
migration_irreversible(name = nil, operation = nil)
migration_irreversible,
migration_not_found(number)
migration_not_found,
migration_not_unique(numbers)
migration_not_unique,
no_migration_yet(version)
no_migration_yet,
null_column_mapping_error(name, type)
null_column_mapping_error,
order_by_error_invalid_order(current_order)
order_by_error_invalid_order,
polymorphic_nil(through)
polymorphic_nil,
polymorphic_unknown_class(class_name)
polymorphic_unknown_class,
query_building_error(message)
query_building_error,
uid_not_found(class_name)
uid_not_found,
uninitialized_db_connection(connection)
uninitialized_db_connection
Class Method Detail
Instance Method Detail
Return true
if the migration has been commited (already applied into the database)
or false
otherwise
Force down a migration; throw error if the mgiration is already down
Print out the status ( up | down ) of all migrations found by the manager.
Force reloading the migration system Recheck all the current up migrations and the metadata table. This is useful if you access to the migration process through another program, or during specs