Created
February 6, 2013 07:30
-
-
Save gudata/4720936 to your computer and use it in GitHub Desktop.
Rails with Joomla Integration.
This is when you have two databases and want to use the migrations.
Use this code until you get rid of Joomla
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| desc "Sync the schema_migrations tables on both databases" | |
| task :sync_schema_migrations => :environment do | |
| class JoomlaSchemaMigrations < ActiveRecord::Base | |
| establish_connection "joomla_#{Rails.env}" | |
| self.table_name = 'schema_migrations' | |
| self.inheritance_column = :sti_type | |
| attr_accessible :version | |
| end | |
| class RailsSchemaMigrations < ActiveRecord::Base | |
| self.table_name = 'schema_migrations' | |
| self.inheritance_column = :sti_type | |
| attr_accessible :version | |
| end | |
| joomla_migrations = JoomlaSchemaMigrations.all.collect(&:version) | |
| rails_migrations = RailsSchemaMigrations.all.collect(&:version) | |
| migrations_missing_in_rails = joomla_migrations - rails_migrations | |
| migrations_missing_in_joomla = rails_migrations - joomla_migrations | |
| puts "filling up the rails schema_migrations" | |
| migrations_missing_in_rails.each do |version| | |
| puts " adding...#{version}" | |
| RailsSchemaMigrations.create(:version => version) | |
| end | |
| puts "filling up the joomla schema_migrations" | |
| migrations_missing_in_joomla.each do |version| | |
| puts " adding...#{version}" | |
| JoomlaSchemaMigrations.create(:version => version) | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment