Open martinbarilik opened 6 months ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
@martinbarilik is this still a blocking issue for you?
You can create the schema however you want and then just manually add the necessary record so that your FirmaPublic.pluck(:nazov_schemy)
returns your new schema. I'm not sure if you need Apartment to handle your usecase? At the same time, I'd be happy to look over a PR if you thought that Apartment should cover this case!
I've got a database with 100+ tables and hundreds of schemas including public schema which is the one with shared data of other schemas ( data that is the same for all schemas ), mostly codebooks, currency rates and so on.
I am trying to assign foreign keys from specific schemas to a public schema where the shared data is.
Assigning foreign keys to a public schema is no problem for postgresql, but creating database from structure.sql is.
I need to recreate database for test purposes.
Apartment::Tenant.create("tenant_name") is by default using public schema to create a new schema, but structure.sql's dump of public is missing assignments because i suppose it replaces all public. prefixes with a tenant_name., therefore i am forced to use _apartment_template schema to create new schema where these prefixes are not replaced ( only _apartment_template. is replaced, but public. stays untouched )
I am fighting to find a way to create tenant with template other then public.
Expected behavior
Apartment::Tenant.create("tenant_name") uses schema _apartment_template as template for creating new schema
Actual behavior
Apartment::Tenant.create("tenant_name") uses public schema by default to create new schema
System configuration
Debian 9+
structure.sql can be generated with both, public and _apartment_template when adding _apartment_template to search_schema_path. There was a discussion a long while ago to implement this but i guess it was never implemented. When public schema is created, these foreign keys are farwarded to public there fore public. prefix is missing which is fine. Using schema.rb is no-go for obvious reasons.
Database: (Tell us what database and its version you use.) Postgresql 11+
Apartment version: 3.0.4
Apartment config (in
config/initializers/apartment.rb
or so):use_schemas
: trueRails (or ActiveRecord) version: Rails 7.0.4
Ruby version: 3.1.5