Skip to content

Table prefix and suffix for multi-tenant environment #125

@fourdim

Description

@fourdim

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:

Artist2 := Artist.FromSchema("chinook2")

As MySQL treats schema the same as database, 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:

Artist2 := Artist.WithPrefix("chinook2")
Artist3 := Artist.WithSuffix("chinook2")
func (a {{tableTemplate.TypeName}}) WithPrefix(prefix string) {{tableTemplate.TypeName}} {
	return new{{tableTemplate.TypeName}}(a.SchemaName(), prefix+a.TableName(), a.Alias())
}

Or simply export the function new{{tableTemplate.TypeName}}.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions