Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lib/erd/migrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Migrator
class << self
def status
migrations = []
migration_table_name = defined?(ActiveRecord::SchemaMigration) ? ActiveRecord::SchemaMigration.table_name : ActiveRecord::Migrator.schema_migrations_table_name
migration_table_name = find_schema_migration_table_name
return migrations unless ActiveRecord::Base.connection.table_exists? migration_table_name

migrated_versions = ActiveRecord::Base.connection.select_values("SELECT version FROM #{migration_table_name}").map {|v| '%.3d' % v}
Expand Down Expand Up @@ -49,6 +49,15 @@ def run_migrations(migrations)
end
#TODO unload migraion classes
end

private

def find_schema_migration_table_name
return ActiveRecord::Migrator.schema_migrations_table_name unless defined?(ActiveRecord::SchemaMigration)
return ActiveRecord::SchemaMigration.table_name if ActiveRecord::SchemaMigration.respond_to?(:table_name)

ActiveRecord::Base.connection.schema_migration.table_name
end
end
end
end