add table prefix and suffix for multi-tenant environment support
This closes #125.
This commit is contained in:
parent
c29f0afd2b
commit
87cc6c9e93
9 changed files with 100 additions and 0 deletions
|
|
@ -42,6 +42,16 @@ func (a ActorTable) FromSchema(schemaName string) *ActorTable {
|
|||
return newActorTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new ActorTable with assigned table prefix
|
||||
func (a ActorTable) WithPrefix(prefix string) *ActorTable {
|
||||
return newActorTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new ActorTable with assigned table suffix
|
||||
func (a ActorTable) WithSuffix(suffix string) *ActorTable {
|
||||
return newActorTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newActorTable(schemaName, tableName, alias string) *ActorTable {
|
||||
return &ActorTable{
|
||||
actorTable: newActorTableImpl(schemaName, tableName, alias),
|
||||
|
|
|
|||
|
|
@ -41,6 +41,16 @@ func (a CategoryTable) FromSchema(schemaName string) *CategoryTable {
|
|||
return newCategoryTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new CategoryTable with assigned table prefix
|
||||
func (a CategoryTable) WithPrefix(prefix string) *CategoryTable {
|
||||
return newCategoryTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new CategoryTable with assigned table suffix
|
||||
func (a CategoryTable) WithSuffix(suffix string) *CategoryTable {
|
||||
return newCategoryTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newCategoryTable(schemaName, tableName, alias string) *CategoryTable {
|
||||
return &CategoryTable{
|
||||
categoryTable: newCategoryTableImpl(schemaName, tableName, alias),
|
||||
|
|
|
|||
|
|
@ -51,6 +51,16 @@ func (a FilmTable) FromSchema(schemaName string) *FilmTable {
|
|||
return newFilmTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new FilmTable with assigned table prefix
|
||||
func (a FilmTable) WithPrefix(prefix string) *FilmTable {
|
||||
return newFilmTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new FilmTable with assigned table suffix
|
||||
func (a FilmTable) WithSuffix(suffix string) *FilmTable {
|
||||
return newFilmTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newFilmTable(schemaName, tableName, alias string) *FilmTable {
|
||||
return &FilmTable{
|
||||
filmTable: newFilmTableImpl(schemaName, tableName, alias),
|
||||
|
|
|
|||
|
|
@ -41,6 +41,16 @@ func (a FilmActorTable) FromSchema(schemaName string) *FilmActorTable {
|
|||
return newFilmActorTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new FilmActorTable with assigned table prefix
|
||||
func (a FilmActorTable) WithPrefix(prefix string) *FilmActorTable {
|
||||
return newFilmActorTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new FilmActorTable with assigned table suffix
|
||||
func (a FilmActorTable) WithSuffix(suffix string) *FilmActorTable {
|
||||
return newFilmActorTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newFilmActorTable(schemaName, tableName, alias string) *FilmActorTable {
|
||||
return &FilmActorTable{
|
||||
filmActorTable: newFilmActorTableImpl(schemaName, tableName, alias),
|
||||
|
|
|
|||
|
|
@ -41,6 +41,16 @@ func (a FilmCategoryTable) FromSchema(schemaName string) *FilmCategoryTable {
|
|||
return newFilmCategoryTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new FilmCategoryTable with assigned table prefix
|
||||
func (a FilmCategoryTable) WithPrefix(prefix string) *FilmCategoryTable {
|
||||
return newFilmCategoryTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new FilmCategoryTable with assigned table suffix
|
||||
func (a FilmCategoryTable) WithSuffix(suffix string) *FilmCategoryTable {
|
||||
return newFilmCategoryTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newFilmCategoryTable(schemaName, tableName, alias string) *FilmCategoryTable {
|
||||
return &FilmCategoryTable{
|
||||
filmCategoryTable: newFilmCategoryTableImpl(schemaName, tableName, alias),
|
||||
|
|
|
|||
|
|
@ -41,6 +41,16 @@ func (a LanguageTable) FromSchema(schemaName string) *LanguageTable {
|
|||
return newLanguageTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new LanguageTable with assigned table prefix
|
||||
func (a LanguageTable) WithPrefix(prefix string) *LanguageTable {
|
||||
return newLanguageTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new LanguageTable with assigned table suffix
|
||||
func (a LanguageTable) WithSuffix(suffix string) *LanguageTable {
|
||||
return newLanguageTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newLanguageTable(schemaName, tableName, alias string) *LanguageTable {
|
||||
return &LanguageTable{
|
||||
languageTable: newLanguageTableImpl(schemaName, tableName, alias),
|
||||
|
|
|
|||
|
|
@ -42,6 +42,16 @@ func (a ActorInfoTable) FromSchema(schemaName string) *ActorInfoTable {
|
|||
return newActorInfoTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new ActorInfoTable with assigned table prefix
|
||||
func (a ActorInfoTable) WithPrefix(prefix string) *ActorInfoTable {
|
||||
return newActorInfoTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new ActorInfoTable with assigned table suffix
|
||||
func (a ActorInfoTable) WithSuffix(suffix string) *ActorInfoTable {
|
||||
return newActorInfoTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newActorInfoTable(schemaName, tableName, alias string) *ActorInfoTable {
|
||||
return &ActorInfoTable{
|
||||
actorInfoTable: newActorInfoTableImpl(schemaName, tableName, alias),
|
||||
|
|
|
|||
|
|
@ -47,6 +47,16 @@ func (a CustomerListTable) FromSchema(schemaName string) *CustomerListTable {
|
|||
return newCustomerListTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new CustomerListTable with assigned table prefix
|
||||
func (a CustomerListTable) WithPrefix(prefix string) *CustomerListTable {
|
||||
return newCustomerListTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new CustomerListTable with assigned table suffix
|
||||
func (a CustomerListTable) WithSuffix(suffix string) *CustomerListTable {
|
||||
return newCustomerListTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newCustomerListTable(schemaName, tableName, alias string) *CustomerListTable {
|
||||
return &CustomerListTable{
|
||||
customerListTable: newCustomerListTableImpl(schemaName, tableName, alias),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue