I'm developing a multitenant app following this article. The problem is when I run all migrations the first time. In schema.rb
file are only the tables for the public schema but what happend with the others schemas? and how can I create others schemas with different structure to the public
I don't want to use gems.
See the example below
Table to be created for public schema
class CreatePerspectives < ActiveRecord::Migration
include MultiSchema
def up
with_in_schemas :only => :public do
# Create table perspectives
end
end
def down
with_in_schemas :only => :public do
drop_table :prespectives
end
end
end
Table to be created for private schemas
class CreateObjectives < ActiveRecord::Migration
include MultiSchema
def change
with_in_schemas :except => :public do
# Create objectives table
end
end
end
schema.rb
ActiveRecord::Schema.define(version: 20130810172443) do
create_table "perspectives", force: true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
end
end
do you know Apartment gem? https://github.com/influitive/apartment
I used in a project on this year, that one supports multi schema with postgresql. Everything is documented and easy to use. And you can chose the Middleware mode. For example, when you access the domain customer.applicationdomain.com the application can select the right schema for you. By the way you can use background jobs with sidekiq too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With