Class: ActiveRecord::SiteMigrator

Inherits:
Migrator
  • Object
show all
Defined in:
lib/productize.rb

Overview

Allow for site-specific migrations by adding a “site_version” field to the schema_info table

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.current_versionObject



48
49
50
# File 'lib/productize.rb', line 48

def self.current_version
  ActiveRecord::Base.connection.select_one("SELECT site_version FROM schema_info")["site_version"].to_i
end

Instance Method Details

#set_schema_version(version) ⇒ Object



52
53
54
# File 'lib/productize.rb', line 52

def set_schema_version(version)
  ActiveRecord::Base.connection.update("UPDATE schema_info SET site_version = #{down? ? version.to_i - 1 : version.to_i}")
end