Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use information schema as the default behaviour for MySQL driver #81

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,20 @@ Configure the Repo you will use to execute the database commands with:
### Additional configuration for MySQL

In MySQL, each tenant will have its own MySQL database.
Triplex uses a table called `tenants` in the main Repo to keep track of the different tenants.
Generate the migration that will create the table by running:
Triplex used to use a table called `tenants` in the main Repo to keep track of the different tenants.
If you wish to keep this behavior, generate the migration that will create the table by running:

mix triplex.mysql.install

And then create the table:

mix ecto.migrate

Otherwise, if you wish to skip this behavior, configure Triplex to use the default `information_schema.schemata` table:
Finally, configure Triplex to use the `tenants` table:

config :triplex, tenant_table: :"information_schema.schemata"
config :triplex, tenant_table: :tenants

Otherwise, Triplex will continue to use the `information_schema.schemata` table as the default behavior for storing tenants.

## Usage

Expand Down
2 changes: 2 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ config :triplex,
~r/^db\d+$/
]

config :triplex, tenant_table: :tenants

# Configure your database
config :triplex, ecto_repos: [Triplex.PGTestRepo, Triplex.MSTestRepo]

Expand Down
2 changes: 1 addition & 1 deletion lib/triplex/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ defmodule Triplex.Config do
migrations_path: "tenant_migrations",
reserved_tenants: [],
tenant_field: :id,
tenant_table: :tenants
tenant_table: :"information_schema.schemata"
]
end