Sign in through GitHub

Please read for an updated status on RailsCasts:

Learn more or hide this

ohenrik's Profile

GitHub User: ohenrik

Comments by

Avatar

If anyone are looking for a way to exclude new tables from the multitenant migration (i.e. Only create the new table in the public schema). This solved the problem for me:

ruby
if ActiveRecord::Base.connection.current_schema == 'public'
Your migration 
end

Complete example

ruby
class UsersHasAndBelongsToManyRoles < ActiveRecord::Migration
        def change
                if ActiveRecord::Base.connection.current_schema == 'public'
                        create_table :roles do |t|
                                t.string :role
                                t.timestamps
                        end

                        create_table :roles_users do |t|
                                t.belongs_to :user, :null => false
                                t.belongs_to :role, :null => false
                        end

                end
        end
end
Avatar

Thank you!

If i deploy this application. will i be able to do the same change to a similar file on a linux server?