Class: ClickhouseActiverecord::MigrationContext
- Inherits:
-
ActiveRecord::MigrationContext
- Object
- ActiveRecord::MigrationContext
- ClickhouseActiverecord::MigrationContext
- Defined in:
- lib/clickhouse-activerecord/migration.rb
Overview
:nodoc:
Instance Attribute Summary collapse
-
#migrations_paths ⇒ Object
readonly
Returns the value of attribute migrations_paths.
-
#schema_migration ⇒ Object
readonly
Returns the value of attribute schema_migration.
Instance Method Summary collapse
- #down(target_version = nil) ⇒ Object
- #get_all_versions ⇒ Object
-
#initialize(migrations_paths, schema_migration) ⇒ MigrationContext
constructor
A new instance of MigrationContext.
- #up(target_version = nil) ⇒ Object
Constructor Details
#initialize(migrations_paths, schema_migration) ⇒ MigrationContext
Returns a new instance of MigrationContext.
79 80 81 82 |
# File 'lib/clickhouse-activerecord/migration.rb', line 79 def initialize(migrations_paths, schema_migration) @migrations_paths = migrations_paths @schema_migration = schema_migration end |
Instance Attribute Details
#migrations_paths ⇒ Object (readonly)
Returns the value of attribute migrations_paths.
77 78 79 |
# File 'lib/clickhouse-activerecord/migration.rb', line 77 def migrations_paths @migrations_paths end |
#schema_migration ⇒ Object (readonly)
Returns the value of attribute schema_migration.
77 78 79 |
# File 'lib/clickhouse-activerecord/migration.rb', line 77 def schema_migration @schema_migration end |
Instance Method Details
#down(target_version = nil) ⇒ Object
94 95 96 97 98 99 100 101 102 |
# File 'lib/clickhouse-activerecord/migration.rb', line 94 def down(target_version = nil) selected_migrations = if block_given? migrations.select { |m| yield m } else migrations end ClickhouseActiverecord::Migrator.new(:down, selected_migrations, schema_migration, target_version).migrate end |
#get_all_versions ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/clickhouse-activerecord/migration.rb', line 104 def get_all_versions if schema_migration.table_exists? schema_migration.all_versions.map(&:to_i) else [] end end |
#up(target_version = nil) ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/clickhouse-activerecord/migration.rb', line 84 def up(target_version = nil) selected_migrations = if block_given? migrations.select { |m| yield m } else migrations end ClickhouseActiverecord::Migrator.new(:up, selected_migrations, schema_migration, target_version).migrate end |