Skip to content

Commit

Permalink
Merge branch 'master' into releases/0.22.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoertink committed Nov 30, 2021
2 parents ec59086 + b1fb701 commit a66f7a4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/avram/migrator/migration.cr
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ abstract class Avram::Migrator::Migration::V1
macro inherited
Avram::Migrator::Runner.migrations << self

def version
get_version_from_filename
def version : Int64
get_version_from_filename.to_i64
end

macro get_version_from_filename
Expand All @@ -19,7 +19,7 @@ abstract class Avram::Migrator::Migration::V1
end

abstract def migrate
abstract def version
abstract def version : Int64

getter prepared_statements = [] of String

Expand Down
10 changes: 3 additions & 7 deletions src/avram/migrator/runner.cr
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Avram::Migrator::Runner

extend LuckyTask::TextHelpers

@@migrations = [] of Avram::Migrator::Migration::V1.class
class_getter migrations = [] of Avram::Migrator::Migration::V1.class

def initialize(@quiet : Bool = false)
end
Expand All @@ -33,10 +33,6 @@ class Avram::Migrator::Runner
credentials.password
end

def self.migrations
@@migrations
end

def self.credentials
Avram.settings.database_to_migrate.credentials
end
Expand Down Expand Up @@ -166,7 +162,7 @@ class Avram::Migrator::Runner
def rollback_to(last_version : Int64)
self.class.setup_migration_tracking_tables
subset = migrated_migrations.select do |mm|
mm.new.version.to_i64 > last_version
mm.new.version > last_version
end
subset.reverse.each &.new.down
puts "Done rolling back to #{last_version}".colorize(:green)
Expand Down Expand Up @@ -205,7 +201,7 @@ class Avram::Migrator::Runner
end

private def sorted_migrations
@@migrations.sort { |a, b| a.new.version <=> b.new.version }
self.class.migrations.sort_by(&.new.version)
end

private def prepare_for_migration
Expand Down

0 comments on commit a66f7a4

Please sign in to comment.