Class | Sequel::TimestampMigrator |
In: |
lib/sequel/extensions/migration.rb
|
Parent: | Migrator |
The migrator used if any migration file version is greater than 20000101. Stores filenames of migration files, and can figure out which migrations have not been applied and apply them, even if earlier migrations are added after later migrations. If you plan to do that, the responsibility is on you to make sure the migrations don‘t conflict. Part of the migration extension.
Error | = | Migrator::Error |
applied_migrations | [R] | Array of strings of applied migration filenames |
migration_tuples | [R] | Get tuples of migrations, filenames, and actions for each migration |
Set up all state for the migrator instance
# File lib/sequel/extensions/migration.rb, line 664 664: def initialize(db, directory, opts=OPTS) 665: super 666: @target = opts[:target] 667: @applied_migrations = get_applied_migrations 668: @migration_tuples = get_migration_tuples 669: end
The timestamp migrator is current if there are no migrations to apply in either direction.
# File lib/sequel/extensions/migration.rb, line 673 673: def is_current? 674: migration_tuples.empty? 675: end
Apply all migration tuples on the database
# File lib/sequel/extensions/migration.rb, line 678 678: def run 679: migration_tuples.each do |m, f, direction| 680: t = Time.now 681: db.log_info("Begin applying migration #{f}, direction: #{direction}") 682: checked_transaction(m) do 683: m.apply(db, direction) 684: fi = f.downcase 685: direction == :up ? ds.insert(column=>fi) : ds.where(column=>fi).delete 686: end 687: db.log_info("Finished applying migration #{f}, direction: #{direction}, took #{sprintf('%0.6f', Time.now - t)} seconds") 688: end 689: nil 690: end