Class: ActiveWarehouse::Migrator
- Inherits:
-
ActiveRecord::Migrator
- Object
- ActiveRecord::Migrator
- ActiveWarehouse::Migrator
- Defined in:
- lib/active_warehouse/migrations.rb
Overview
Responsible for migrating ActiveWarehouse tables which are automatically created.
Class Method Summary collapse
-
.current_version ⇒ Object
:nodoc:.
-
.schema_info_table_name ⇒ Object
:nodoc:.
Instance Method Summary collapse
Class Method Details
.current_version ⇒ Object
:nodoc:
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/active_warehouse/migrations.rb', line 9 def current_version #:nodoc: result = ActiveRecord::Base.connection.select_one("SELECT version FROM #{schema_info_table_name}") if result result['version'].to_i else # There probably isn't an entry for this plugin in the migration info table. # We need to create that entry, and set the version to 0 ActiveRecord::Base.connection.execute("INSERT INTO #{schema_info_table_name} (version) VALUES (0)") 0 end end |
.schema_info_table_name ⇒ Object
:nodoc:
5 6 7 |
# File 'lib/active_warehouse/migrations.rb', line 5 def schema_info_table_name #:nodoc: ActiveRecord::Base.table_name_prefix + 'activewarehouse_schema_info' + ActiveRecord::Base.table_name_suffix end |
Instance Method Details
#set_schema_version(version) ⇒ Object
22 23 24 |
# File 'lib/active_warehouse/migrations.rb', line 22 def set_schema_version(version) ActiveRecord::Base.connection.update("UPDATE #{self.class.schema_info_table_name} SET version = #{down? ? version.to_i - 1 : version.to_i}") end |