added establish_connection to migrations

Jeremy Steinberg committed Aug 29, 2011
commit 66c318ba280a7485d0cd87083943056237446e1a
Showing 6 changed files with 12 additions and 1 deletions
config/initializers/comfortable_mexican_sofa.rb +1 -1
@@ @@ -53,7 +53,7 @@ ComfortableMexicanSofa.configure do |config|
# in a location other than the default databases add a database_prefix.
# Using a prefix of `cms_` will look for a cms_#{Rails.env} definition
# in your database.yml file
- config.database_prefix = 'cms_'
+ # config.database_prefix = 'cms_'
end
migrate/01_create_cms.rb b/db/migrate/01_create_cms.rb +3 -0
@@ @@ -1,6 +1,7 @@
class CreateCms < ActiveRecord::Migration
def self.up
+ ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}"
# -- Sites --------------------------------------------------------------
create_table :cms_sites do |t|
t.string :label
@@ @@ -107,6 +108,8 @@ class CreateCms < ActiveRecord::Migration
end
def self.down
+ ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}"
+
drop_table :cms_sites
drop_table :cms_layouts
drop_table :cms_pages
migrate/upgrades/02_upgrade_to_1_1_0.rb b/db/migrate/upgrades/02_upgrade_to_1_1_0.rb +2 -0
@@ @@ -1,5 +1,6 @@
class UpgradeTo110 < ActiveRecord::Migration
def self.up
+ ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}"
rename_column :cms_layouts, :cms_site_id, :site_id
rename_column :cms_pages, :cms_site_id, :site_id
rename_column :cms_pages, :cms_layout_id, :layout_id
@@ @@ -9,6 +10,7 @@ class UpgradeTo110 < ActiveRecord::Migration
end
def self.down
+ ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}"
rename_column :cms_uploads, :site_id, :cms_site_id
rename_column :cms_snippets, :site_id, :cms_site_id
rename_column :cms_blocks, :page_id, :cms_page_id
migrate/upgrades/03_upgrade_to_1_2_0.rb b/db/migrate/upgrades/03_upgrade_to_1_2_0.rb +2 -0
@@ @@ -1,5 +1,6 @@
class UpgradeTo120 < ActiveRecord::Migration
def self.up
+ ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}"
create_table :cms_revisions, :force => true do |t|
t.string :record_type
t.integer :record_id
@@ @@ -10,6 +11,7 @@ class UpgradeTo120 < ActiveRecord::Migration
end
def self.down
+ ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}"
drop_table :cms_revisions
end
end
\ No newline at end of file
migrate/upgrades/04_upgrade_to_1_3_0.rb b/db/migrate/upgrades/04_upgrade_to_1_3_0.rb +2 -0
@@ @@ -1,5 +1,6 @@
class UpgradeTo130 < ActiveRecord::Migration
def self.up
+ ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}"
add_column :cms_sites, :is_mirrored, :boolean, :null => false, :default => false
add_column :cms_sites, :path, :string
add_column :cms_sites, :locale, :string, :null => false, :default => 'en'
@@ @@ -11,6 +12,7 @@ class UpgradeTo130 < ActiveRecord::Migration
end
def self.down
+ ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}"
remove_index :cms_sites, :is_mirrored
remove_column :cms_sites, :path
remove_column :cms_sites, :is_mirrored
migrate/upgrades/05_upgrade_to_1_4_0.rb b/db/migrate/upgrades/05_upgrade_to_1_4_0.rb +2 -0
@@ @@ -1,5 +1,6 @@
class UpgradeTo140 < ActiveRecord::Migration
def self.up
+ ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}"
rename_table :cms_uploads, :cms_files
add_column :cms_files, :label, :string
add_column :cms_files, :description, :string, :limit => 2048
@@ @@ -22,6 +23,7 @@ class UpgradeTo140 < ActiveRecord::Migration
end
def self.down
+ ActiveRecord::Base.establish_connection "#{ComfortableMexicanSofa.config.database_prefix}#{Rails.env}"
remove_index :cms_files, [:site_id, :label]
remove_column :cms_files, :description
remove_column :cms_files, :label