-
Notifications
You must be signed in to change notification settings - Fork 125
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
Table prefix and suffix for multi-tenant environment #125
Comments
Hi @fourdim. Yeah, it make sense to add What's your plan in general? If we change table name, we will also change default aliasing so return new{{tableTemplate.TypeName}}(a.SchemaName(), prefix+a.TableName(), a.TableName()) |
My plan is to have
It seems that you are right. And I think this plan is good enough for me to solve the multi-tenant problem. |
Do you want to open a PR? Contributions are always welcomed. |
* add table prefix and suffix for multi-tenant environment support This closes go-jet#125. * Update generator tests * Bump github.com/lib/pq from 1.7.0 to 1.10.5 Bumps [github.com/lib/pq](https://github.com/lib/pq) from 1.7.0 to 1.10.5. - [Release notes](https://github.com/lib/pq/releases) - [Commits](lib/pq@v1.7.0...v1.10.5) --- updated-dependencies: - dependency-name: github.com/lib/pq dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * fix -ignore-tables, -ignore-enums and -ignore-views when -dsn is present * Bump github.com/jackc/pgx/v4 from 4.11.0 to 4.16.0 Bumps [github.com/jackc/pgx/v4](https://github.com/jackc/pgx) from 4.11.0 to 4.16.0. - [Release notes](https://github.com/jackc/pgx/releases) - [Changelog](https://github.com/jackc/pgx/blob/master/CHANGELOG.md) - [Commits](jackc/pgx@v4.11.0...v4.16.0) --- updated-dependencies: - dependency-name: github.com/jackc/pgx/v4 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Add support for CockorachDB. * Add support for EXTRACT time/date function. * Generator code cleanup. * Improve doc. * [Bug] Statement Query and Exec methods can not be used with sql.Conn * Update dependencies. * [Bug] DebugSQL panics with libraries that do not implemente Stringer interface. * Update README.md * Add multi-tenant table `WithPrefix`, `WithSuffix` tests. * Add multi-tenant table `WithPrefix`, `WithSuffix` tests. * mysql: export some conditional functions COALESCE, NULLIF, GREATEST and LEAST already existed and were available in the postgres dialect, but not in MySQL. * add postgres json literal * Better json func, and tests * Update badge links. * Add missing sqlite conditional functions. * add missing SET method to ColumnTimez interface it has been already implemented, just missing from interface * [MySQL] Add NEW alias for the rows to be inserted. * Go fmt. * Add omitted reserved word 'right' on postgresql * [MySQL] Optimizer hints * [postgres] Add Json literal test. * Potential security flaw I am using go-jet as a go library for an application that uses dynamic database credentials and noticed this potential security risk that exposes the whole database credentials (though it is timed, it is still a risk) * Removed dsn from generator * fix: Updating query for types to the target namespace Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: fourdim <[email protected]> Co-authored-by: go-jet <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Nikita Konin <[email protected]> Co-authored-by: go-jet <[email protected]> Co-authored-by: Karl Blomster <[email protected]> Co-authored-by: Vladimír Zahradník <[email protected]> Co-authored-by: Stefan <[email protected]> Co-authored-by: S T E P H E N <[email protected]>
Feature needed
Hi, there. I've read the wiki and learnt that the solution for jet to manage multi-tenant environment is to use the function:
As MySQL treats
schema
the same asdatabase
, I would like to have a multi-tenant environment based on the prefix or suffix of tables.Suggested solution
Modify the generator by adding the functions like:
Or simply export the function
new{{tableTemplate.TypeName}}
.The text was updated successfully, but these errors were encountered: