feat: support bind user to tenants

This commit is contained in:
Rogee
2024-12-12 19:26:48 +08:00
parent 259b334711
commit 8a1477e991
7 changed files with 113 additions and 2 deletions

View File

@@ -0,0 +1,10 @@
-- +goose Up
-- +goose StatementBegin
-- add column bind_user_id to tenants
ALTER TABLE tenants ADD COLUMN bind_user_id INT8 NOT NULL DEFAULT 0;
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP COLUMN bind_user_id FROM tenants;
-- +goose StatementEnd

View File

@@ -19,4 +19,5 @@ type Tenants struct {
ExpireAt time.Time `json:"expire_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
BindUserID int64 `json:"bind_user_id"`
}

View File

@@ -24,6 +24,7 @@ type tenantsTable struct {
ExpireAt postgres.ColumnTimestamp
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
BindUserID postgres.ColumnInteger
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
@@ -71,8 +72,9 @@ func newTenantsTableImpl(schemaName, tableName, alias string) tenantsTable {
ExpireAtColumn = postgres.TimestampColumn("expire_at")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
allColumns = postgres.ColumnList{IDColumn, NameColumn, SlugColumn, DescriptionColumn, ExpireAtColumn, CreatedAtColumn, UpdatedAtColumn}
mutableColumns = postgres.ColumnList{NameColumn, SlugColumn, DescriptionColumn, ExpireAtColumn, CreatedAtColumn, UpdatedAtColumn}
BindUserIDColumn = postgres.IntegerColumn("bind_user_id")
allColumns = postgres.ColumnList{IDColumn, NameColumn, SlugColumn, DescriptionColumn, ExpireAtColumn, CreatedAtColumn, UpdatedAtColumn, BindUserIDColumn}
mutableColumns = postgres.ColumnList{NameColumn, SlugColumn, DescriptionColumn, ExpireAtColumn, CreatedAtColumn, UpdatedAtColumn, BindUserIDColumn}
)
return tenantsTable{
@@ -86,6 +88,7 @@ func newTenantsTableImpl(schemaName, tableName, alias string) tenantsTable {
ExpireAt: ExpireAtColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
BindUserID: BindUserIDColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,