Comments (7)
Even if it wasn't looking for a hardcoded schema.rb file, schema.sql doesn't work, as the Rails dumper doesn't play too well with multiple schemas the last time I tried it. It's probably fixable, but it would involve some modifications of some rake tasks, particularly db:schema:dump
and db:schema:load
. If you want to take a look, we'd welcome a pull request - we use hstore as well and have a few workarounds to get around being unable to dump a sql schema.
from apartment.
Do you have the workaround documented anywhere? I am not sure i will have time to fix this for a while so it may come in useful.
from apartment.
Also I'd like to notice that using schema.rb doesn't solve the problem if the database has complex structure with triggers and functions. These are just silently ommited in the schema.rb
As a workaround it might be possible to run all the migrations against the new schema on create instead...
Yes, it might take much longer then loading schema.rb, but it should preserve the DB code.
So it would be great to have such an option.
from apartment.
i dont' think we'd recommend this type of behaviour. Migrations are not meant to be the definitive source for your db, the schema is. Migrations become unreliable on larger projects as refactorings take place. They're not even guaranteed to run start to end at that point. We often clean up our migration directory as it piles up.
Yes we're limited with schema.rb
. We'll have to discuss some solutions for supporting things like contraints that may be added through migrations.
from apartment.
Generating and using db/structure.sql
can help, but I don't know if it can be easily applied to some specified schema other then the one used at the dump time. I finally used the split-migration approach applying the tenant part of the migrations with ActiveRecord::Migrator
every time a tenant gets created or needs a schema update.
from apartment.
I think I just read in the latest 3.2.14 release that they've fixed the dumping?
from apartment.
Ya I guess you're referring to this in the changelog:
Resets the postgres search path in the structure.sql after the structure is dumped in order to find schema_migrations table when multiples schemas are used. Fixes #9796.
Might be worth a look into it. We could probably allow a config option for the dump type (ie :sql, or :ruby) or something to that affect.
from apartment.
Related Issues (20)
- Single Tenant's Column Metadata Cached & Used for All Tenants HOT 1
- Active Record Relation delaying query till after switching to default shard
- Reverting schema based multi tenancy to single schema foreign key based multi tenancy HOT 1
- Rails 5: ActiveRecord::ConnectionNotEstablished: No connection pool with id primary found HOT 1
- Switch from subdomains to generic elevator HOT 1
- how can I redirect to tenant on creation? No devise or warden
- Doesn't work with Rails 6 HOT 1
- warning: instance variable not initialized HOT 1
- write RSpec tests for APIs HOT 1
- ActiveRecord::StatementInvalid: PG::UndefinedObject: ERROR: operator class "gin_trgm_ops" does not exist for access method "gin" HOT 1
- Apartment 2.2 is not compatible with ActiveRecord 3
- raw SQL doesn't get interpreted by apartment to use schemas
- 2.2.1 not compatible with Rails 6.1 HOT 1
- excluded_models does not works with db:setup HOT 1
- Making a request to an ActiveStorage resource fails occasionally
- Direct uploads writing to random tenants HOT 1
- Fresh install on Rails 7.0.4 can't setup HOT 2
- Not able to configure New Relic for each apartment separately
- Not able find a solution for multi db connection HOT 2
- Find with Parameter 1 but SQL query taking it as NULL
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apartment.