Skip to content

Persistent schemas, excluded models, shared extensions, SQL VS .rb and future plans  #152

@NielsKSchjoedt

Description

@NielsKSchjoedt

Hi all,

I'm a happy user of apartment with my rails 4 app and a postgresql database. My use case touches all areas of issues that comes from functionalities mentioned in the headline.

Now, I'm starting to get confused about all the PR's coming in tackling various pieces of the problems that comes from: having the excluded models and the tenanted models only reside in either a shared schema or a tenanted schema #117, having FK constraints between an excluded model and a tenanted model, having shared extensions like hstore #141, being able to correctly dump the schema including the cross-scema constraints and the shared extensions, and again loading it all correctly when creating a new tenant #16 or a tests database.

Now I thought that it might be a good idea to have a small discussion about the current state of the gem and the goal of how it "should be", so we can work in the same direction, when fixing bugs and implementing new functionality.

Now consider the following setup:

Let's say we have a blogging app with multiple blogs about food and wine. The blog contains a model called post which has many comments. The blog uses both hstore functionality and postgis functionality, so they need to be alway available. A user can create posts in all blogs, so the user model needs to be an excluded_model. From my knowledge, the best way to set this up using apartment and postgres would be like so:

config.use_sql = true # to be able to dump the hstore and postgis functions
config.default_schema = "public"
config.persistent_schemas = ["extensions"]
config.excluded_models = ["User"]

Question 1:
Do we agree that the diagram above represents the current recommended setup?

Question 2:
Does this setup imply any issues with migrations, setup of test databases, creating new tenants etc.?

Now consider this diagram of a future version of Apartment:

Question 3:
Do we agree that this diagram above represents how we want apartment to work in the future?

Question 4:
If so, what are the current obstacles to make this work?

I'm sure a lot more of these questions and issues have been touched in many other threads, but I really would appreciate getting a "current state" overview and a more common guideline for the future development.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions