add backend tpl

This commit is contained in:
Rogee
2024-11-28 23:18:11 +08:00
parent 77e962b668
commit f7d95418a2
86 changed files with 3229 additions and 135 deletions

View File

View File

@@ -1,59 +0,0 @@
package database
import (
"database/sql"
"embed"
"sync"
"git.ipao.vip/rogeecn/mp-qvyun/conf"
"github.com/gofiber/fiber/v3/log"
_ "github.com/lib/pq"
"github.com/pkg/errors"
)
//go:embed migrations/*
var MigrationFS embed.FS
var (
mutex sync.Mutex
db *sql.DB
)
func Close() error {
if db == nil {
return nil
}
return db.Close()
}
func GetDB(config conf.Database) (*sql.DB, error) {
mutex.Lock()
defer mutex.Unlock()
if db != nil {
return db, nil
}
once := sync.OnceValues(func() (*sql.DB, error) {
log.Debugf("connect postgres with dsn: '%s'", config.DSN())
db, err := sql.Open("postgres", config.DSN())
if err != nil {
return nil, errors.Wrap(err, "connect database")
}
if err := db.Ping(); err != nil {
db.Close()
return nil, errors.Wrap(err, "ping database")
}
return db, err
})
var err error
db, err = once()
if err != nil {
return nil, err
}
return db, err
}

View File

@@ -1,122 +0,0 @@
-- +goose Up
-- +goose StatementBegin
-- table users
CREATE TABLE
users (
id SERIAL8 PRIMARY KEY,
open_id VARCHAR(128) NOT NULL,
union_id VARCHAR(128),
oauth jsonb ,
expire_in timestamp NOT NULL,
created_at timestamp NOT NULL,
updated_at timestamp NOT NULL
);
CREATE INDEX idx_users_open_id ON users (open_id);
CREATE INDEX idx_users_union_id ON users (union_id);
-- table tenants
CREATE TABLE
tenants (
id SERIAL8 PRIMARY KEY,
name VARCHAR(128) NOT NULL,
slug VARCHAR(128) NOT NULL,
description VARCHAR(128),
expire_at timestamp NOT NULL,
created_at timestamp NOT NULL,
updated_at timestamp NOT NULL
);
-- table users_tenants
CREATE TABLE
users_tenants (
id SERIAL8 PRIMARY KEY,
user_id INT8 NOT NULL,
tenant_id INT8 NOT NULL,
created_at timestamp NOT NULL
);
CREATE INDEX idx_users_tenants_user_id ON users_tenants (user_id);
CREATE INDEX idx_users_tenants_tenant_id ON users_tenants (tenant_id);
CREATE TABLE tenant_user_balances (
id SERIAL8 PRIMARY KEY,
user_id INT8 NOT NULL,
tenant_id INT8 NOT NULL,
balance INT8 NOT NULL
);
CREATE INDEX idx_tenant_user_balance_user_id ON tenant_user_balances (user_id);
CREATE INDEX idx_tenant_user_balance_tenant_id ON tenant_user_balances (tenant_id);
-- table user_balance_history
CREATE TABLE user_balance_histories (
id SERIAL8 PRIMARY KEY,
user_id INT8 NOT NULL,
tenant_id INT8 NOT NULL,
balance INT8 NOT NULL,
target jsonb ,
type VARCHAR(128) NOT NULL, -- charge, consume, refund
created_at timestamp NOT NULL
);
CREATE INDEX idx_user_balance_histories_user_id ON user_balance_histories (user_id);
CREATE INDEX idx_user_balance_histories_tenant_id ON user_balance_histories (tenant_id);
-- medias
CREATE TABLE
medias (
id SERIAL8 PRIMARY KEY,
tenant_id INT8 NOT NULL,
title VARCHAR(198) NOT NULL,
description VARCHAR(198) NOT NULL,
price INT8 NOT NULL,
discount INT8 NOT NULL,
publish BOOL NOT NULL,
created_at timestamp NOT NULL,
updated_at timestamp NOT NULL
);
CREATE INDEX idx_medias_tenant_id ON medias (tenant_id);
CREATE INDEX idx_medias_title ON medias (title);
CREATE TABLE
media_resources (
id SERIAL8 PRIMARY KEY,
media_id INT8 NOT NULL,
type VARCHAR(128) NOT NULL,
source jsonb ,
size INT8 NOT NULL,
publish BOOL NOT NULL,
created_at timestamp NOT NULL,
updated_at timestamp NOT NULL
);
CREATE INDEX idx_media_resources_media_id ON media_resources (media_id);
CREATE TABLE user_medias (
id SERIAL8 PRIMARY KEY,
user_id INT8 NOT NULL,
tenant_id INT8 NOT NULL,
media_id INT8 NOT NULL,
price INT8 NOT NULL,
created_at timestamp NOT NULL
);
CREATE INDEX idx_user_medias_user_id ON user_medias (user_id);
CREATE INDEX idx_user_medias_tenant_id ON user_medias (tenant_id);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE users;
DROP TABLE tenants;
DROP TABLE users_tenants;
DROP TABLE tenant_user_balances;
DROP TABLE user_balance_histories;
DROP TABLE medias;
DROP TABLE media_resources;
DROP TABLE user_medias;
-- +goose StatementEnd

View File

@@ -1,23 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type MediaResources struct {
ID int64 `sql:"primary_key"`
MediaID int64
Type string
Source *string
Size int64
Publish bool
CreatedAt time.Time
UpdatedAt time.Time
}

View File

@@ -1,24 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type Medias struct {
ID int64 `sql:"primary_key"`
TenantID int64
Title string
Description string
Price int64
Discount int64
Publish bool
CreatedAt time.Time
UpdatedAt time.Time
}

View File

@@ -1,19 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type Migrations struct {
ID int32 `sql:"primary_key"`
VersionID int64
IsApplied bool
Tstamp time.Time
}

View File

@@ -1,15 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
type TenantUserBalances struct {
ID int64 `sql:"primary_key"`
UserID int64
TenantID int64
Balance int64
}

View File

@@ -1,22 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type Tenants struct {
ID int64 `sql:"primary_key"`
Name string
Slug string
Description *string
ExpireAt time.Time
CreatedAt time.Time
UpdatedAt time.Time
}

View File

@@ -1,22 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type UserBalanceHistories struct {
ID int64 `sql:"primary_key"`
UserID int64
TenantID int64
Balance int64
Target *string
Type string
CreatedAt time.Time
}

View File

@@ -1,21 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type UserMedias struct {
ID int64 `sql:"primary_key"`
UserID int64
TenantID int64
MediaID int64
Price int64
CreatedAt time.Time
}

View File

@@ -1,22 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type Users struct {
ID int64 `sql:"primary_key"`
OpenID string
UnionID *string
OAuth *string
ExpireIn time.Time
CreatedAt time.Time
UpdatedAt time.Time
}

View File

@@ -1,19 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package model
import (
"time"
)
type UsersTenants struct {
ID int64 `sql:"primary_key"`
UserID int64
TenantID int64
CreatedAt time.Time
}

View File

@@ -1,96 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var MediaResources = newMediaResourcesTable("public", "media_resources", "")
type mediaResourcesTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
MediaID postgres.ColumnInteger
Type postgres.ColumnString
Source postgres.ColumnString
Size postgres.ColumnInteger
Publish postgres.ColumnBool
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type MediaResourcesTable struct {
mediaResourcesTable
EXCLUDED mediaResourcesTable
}
// AS creates new MediaResourcesTable with assigned alias
func (a MediaResourcesTable) AS(alias string) *MediaResourcesTable {
return newMediaResourcesTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new MediaResourcesTable with assigned schema name
func (a MediaResourcesTable) FromSchema(schemaName string) *MediaResourcesTable {
return newMediaResourcesTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new MediaResourcesTable with assigned table prefix
func (a MediaResourcesTable) WithPrefix(prefix string) *MediaResourcesTable {
return newMediaResourcesTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new MediaResourcesTable with assigned table suffix
func (a MediaResourcesTable) WithSuffix(suffix string) *MediaResourcesTable {
return newMediaResourcesTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newMediaResourcesTable(schemaName, tableName, alias string) *MediaResourcesTable {
return &MediaResourcesTable{
mediaResourcesTable: newMediaResourcesTableImpl(schemaName, tableName, alias),
EXCLUDED: newMediaResourcesTableImpl("", "excluded", ""),
}
}
func newMediaResourcesTableImpl(schemaName, tableName, alias string) mediaResourcesTable {
var (
IDColumn = postgres.IntegerColumn("id")
MediaIDColumn = postgres.IntegerColumn("media_id")
TypeColumn = postgres.StringColumn("type")
SourceColumn = postgres.StringColumn("source")
SizeColumn = postgres.IntegerColumn("size")
PublishColumn = postgres.BoolColumn("publish")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
allColumns = postgres.ColumnList{IDColumn, MediaIDColumn, TypeColumn, SourceColumn, SizeColumn, PublishColumn, CreatedAtColumn, UpdatedAtColumn}
mutableColumns = postgres.ColumnList{MediaIDColumn, TypeColumn, SourceColumn, SizeColumn, PublishColumn, CreatedAtColumn, UpdatedAtColumn}
)
return mediaResourcesTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
MediaID: MediaIDColumn,
Type: TypeColumn,
Source: SourceColumn,
Size: SizeColumn,
Publish: PublishColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -1,99 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var Medias = newMediasTable("public", "medias", "")
type mediasTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
TenantID postgres.ColumnInteger
Title postgres.ColumnString
Description postgres.ColumnString
Price postgres.ColumnInteger
Discount postgres.ColumnInteger
Publish postgres.ColumnBool
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type MediasTable struct {
mediasTable
EXCLUDED mediasTable
}
// AS creates new MediasTable with assigned alias
func (a MediasTable) AS(alias string) *MediasTable {
return newMediasTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new MediasTable with assigned schema name
func (a MediasTable) FromSchema(schemaName string) *MediasTable {
return newMediasTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new MediasTable with assigned table prefix
func (a MediasTable) WithPrefix(prefix string) *MediasTable {
return newMediasTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new MediasTable with assigned table suffix
func (a MediasTable) WithSuffix(suffix string) *MediasTable {
return newMediasTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newMediasTable(schemaName, tableName, alias string) *MediasTable {
return &MediasTable{
mediasTable: newMediasTableImpl(schemaName, tableName, alias),
EXCLUDED: newMediasTableImpl("", "excluded", ""),
}
}
func newMediasTableImpl(schemaName, tableName, alias string) mediasTable {
var (
IDColumn = postgres.IntegerColumn("id")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
TitleColumn = postgres.StringColumn("title")
DescriptionColumn = postgres.StringColumn("description")
PriceColumn = postgres.IntegerColumn("price")
DiscountColumn = postgres.IntegerColumn("discount")
PublishColumn = postgres.BoolColumn("publish")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
allColumns = postgres.ColumnList{IDColumn, TenantIDColumn, TitleColumn, DescriptionColumn, PriceColumn, DiscountColumn, PublishColumn, CreatedAtColumn, UpdatedAtColumn}
mutableColumns = postgres.ColumnList{TenantIDColumn, TitleColumn, DescriptionColumn, PriceColumn, DiscountColumn, PublishColumn, CreatedAtColumn, UpdatedAtColumn}
)
return mediasTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
TenantID: TenantIDColumn,
Title: TitleColumn,
Description: DescriptionColumn,
Price: PriceColumn,
Discount: DiscountColumn,
Publish: PublishColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -1,84 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var Migrations = newMigrationsTable("public", "migrations", "")
type migrationsTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
VersionID postgres.ColumnInteger
IsApplied postgres.ColumnBool
Tstamp postgres.ColumnTimestamp
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type MigrationsTable struct {
migrationsTable
EXCLUDED migrationsTable
}
// AS creates new MigrationsTable with assigned alias
func (a MigrationsTable) AS(alias string) *MigrationsTable {
return newMigrationsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new MigrationsTable with assigned schema name
func (a MigrationsTable) FromSchema(schemaName string) *MigrationsTable {
return newMigrationsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new MigrationsTable with assigned table prefix
func (a MigrationsTable) WithPrefix(prefix string) *MigrationsTable {
return newMigrationsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new MigrationsTable with assigned table suffix
func (a MigrationsTable) WithSuffix(suffix string) *MigrationsTable {
return newMigrationsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newMigrationsTable(schemaName, tableName, alias string) *MigrationsTable {
return &MigrationsTable{
migrationsTable: newMigrationsTableImpl(schemaName, tableName, alias),
EXCLUDED: newMigrationsTableImpl("", "excluded", ""),
}
}
func newMigrationsTableImpl(schemaName, tableName, alias string) migrationsTable {
var (
IDColumn = postgres.IntegerColumn("id")
VersionIDColumn = postgres.IntegerColumn("version_id")
IsAppliedColumn = postgres.BoolColumn("is_applied")
TstampColumn = postgres.TimestampColumn("tstamp")
allColumns = postgres.ColumnList{IDColumn, VersionIDColumn, IsAppliedColumn, TstampColumn}
mutableColumns = postgres.ColumnList{VersionIDColumn, IsAppliedColumn, TstampColumn}
)
return migrationsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
VersionID: VersionIDColumn,
IsApplied: IsAppliedColumn,
Tstamp: TstampColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -1,22 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
// UseSchema sets a new schema name for all generated table SQL builder types. It is recommended to invoke
// this method only once at the beginning of the program.
func UseSchema(schema string) {
MediaResources = MediaResources.FromSchema(schema)
Medias = Medias.FromSchema(schema)
Migrations = Migrations.FromSchema(schema)
TenantUserBalances = TenantUserBalances.FromSchema(schema)
Tenants = Tenants.FromSchema(schema)
UserBalanceHistories = UserBalanceHistories.FromSchema(schema)
UserMedias = UserMedias.FromSchema(schema)
Users = Users.FromSchema(schema)
UsersTenants = UsersTenants.FromSchema(schema)
}

View File

@@ -1,84 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var TenantUserBalances = newTenantUserBalancesTable("public", "tenant_user_balances", "")
type tenantUserBalancesTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
UserID postgres.ColumnInteger
TenantID postgres.ColumnInteger
Balance postgres.ColumnInteger
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type TenantUserBalancesTable struct {
tenantUserBalancesTable
EXCLUDED tenantUserBalancesTable
}
// AS creates new TenantUserBalancesTable with assigned alias
func (a TenantUserBalancesTable) AS(alias string) *TenantUserBalancesTable {
return newTenantUserBalancesTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new TenantUserBalancesTable with assigned schema name
func (a TenantUserBalancesTable) FromSchema(schemaName string) *TenantUserBalancesTable {
return newTenantUserBalancesTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new TenantUserBalancesTable with assigned table prefix
func (a TenantUserBalancesTable) WithPrefix(prefix string) *TenantUserBalancesTable {
return newTenantUserBalancesTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new TenantUserBalancesTable with assigned table suffix
func (a TenantUserBalancesTable) WithSuffix(suffix string) *TenantUserBalancesTable {
return newTenantUserBalancesTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newTenantUserBalancesTable(schemaName, tableName, alias string) *TenantUserBalancesTable {
return &TenantUserBalancesTable{
tenantUserBalancesTable: newTenantUserBalancesTableImpl(schemaName, tableName, alias),
EXCLUDED: newTenantUserBalancesTableImpl("", "excluded", ""),
}
}
func newTenantUserBalancesTableImpl(schemaName, tableName, alias string) tenantUserBalancesTable {
var (
IDColumn = postgres.IntegerColumn("id")
UserIDColumn = postgres.IntegerColumn("user_id")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
BalanceColumn = postgres.IntegerColumn("balance")
allColumns = postgres.ColumnList{IDColumn, UserIDColumn, TenantIDColumn, BalanceColumn}
mutableColumns = postgres.ColumnList{UserIDColumn, TenantIDColumn, BalanceColumn}
)
return tenantUserBalancesTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
UserID: UserIDColumn,
TenantID: TenantIDColumn,
Balance: BalanceColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -1,93 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var Tenants = newTenantsTable("public", "tenants", "")
type tenantsTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
Name postgres.ColumnString
Slug postgres.ColumnString
Description postgres.ColumnString
ExpireAt postgres.ColumnTimestamp
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type TenantsTable struct {
tenantsTable
EXCLUDED tenantsTable
}
// AS creates new TenantsTable with assigned alias
func (a TenantsTable) AS(alias string) *TenantsTable {
return newTenantsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new TenantsTable with assigned schema name
func (a TenantsTable) FromSchema(schemaName string) *TenantsTable {
return newTenantsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new TenantsTable with assigned table prefix
func (a TenantsTable) WithPrefix(prefix string) *TenantsTable {
return newTenantsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new TenantsTable with assigned table suffix
func (a TenantsTable) WithSuffix(suffix string) *TenantsTable {
return newTenantsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newTenantsTable(schemaName, tableName, alias string) *TenantsTable {
return &TenantsTable{
tenantsTable: newTenantsTableImpl(schemaName, tableName, alias),
EXCLUDED: newTenantsTableImpl("", "excluded", ""),
}
}
func newTenantsTableImpl(schemaName, tableName, alias string) tenantsTable {
var (
IDColumn = postgres.IntegerColumn("id")
NameColumn = postgres.StringColumn("name")
SlugColumn = postgres.StringColumn("slug")
DescriptionColumn = postgres.StringColumn("description")
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}
)
return tenantsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
Name: NameColumn,
Slug: SlugColumn,
Description: DescriptionColumn,
ExpireAt: ExpireAtColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -1,93 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var UserBalanceHistories = newUserBalanceHistoriesTable("public", "user_balance_histories", "")
type userBalanceHistoriesTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
UserID postgres.ColumnInteger
TenantID postgres.ColumnInteger
Balance postgres.ColumnInteger
Target postgres.ColumnString
Type postgres.ColumnString
CreatedAt postgres.ColumnTimestamp
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type UserBalanceHistoriesTable struct {
userBalanceHistoriesTable
EXCLUDED userBalanceHistoriesTable
}
// AS creates new UserBalanceHistoriesTable with assigned alias
func (a UserBalanceHistoriesTable) AS(alias string) *UserBalanceHistoriesTable {
return newUserBalanceHistoriesTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new UserBalanceHistoriesTable with assigned schema name
func (a UserBalanceHistoriesTable) FromSchema(schemaName string) *UserBalanceHistoriesTable {
return newUserBalanceHistoriesTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new UserBalanceHistoriesTable with assigned table prefix
func (a UserBalanceHistoriesTable) WithPrefix(prefix string) *UserBalanceHistoriesTable {
return newUserBalanceHistoriesTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new UserBalanceHistoriesTable with assigned table suffix
func (a UserBalanceHistoriesTable) WithSuffix(suffix string) *UserBalanceHistoriesTable {
return newUserBalanceHistoriesTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newUserBalanceHistoriesTable(schemaName, tableName, alias string) *UserBalanceHistoriesTable {
return &UserBalanceHistoriesTable{
userBalanceHistoriesTable: newUserBalanceHistoriesTableImpl(schemaName, tableName, alias),
EXCLUDED: newUserBalanceHistoriesTableImpl("", "excluded", ""),
}
}
func newUserBalanceHistoriesTableImpl(schemaName, tableName, alias string) userBalanceHistoriesTable {
var (
IDColumn = postgres.IntegerColumn("id")
UserIDColumn = postgres.IntegerColumn("user_id")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
BalanceColumn = postgres.IntegerColumn("balance")
TargetColumn = postgres.StringColumn("target")
TypeColumn = postgres.StringColumn("type")
CreatedAtColumn = postgres.TimestampColumn("created_at")
allColumns = postgres.ColumnList{IDColumn, UserIDColumn, TenantIDColumn, BalanceColumn, TargetColumn, TypeColumn, CreatedAtColumn}
mutableColumns = postgres.ColumnList{UserIDColumn, TenantIDColumn, BalanceColumn, TargetColumn, TypeColumn, CreatedAtColumn}
)
return userBalanceHistoriesTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
UserID: UserIDColumn,
TenantID: TenantIDColumn,
Balance: BalanceColumn,
Target: TargetColumn,
Type: TypeColumn,
CreatedAt: CreatedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -1,90 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var UserMedias = newUserMediasTable("public", "user_medias", "")
type userMediasTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
UserID postgres.ColumnInteger
TenantID postgres.ColumnInteger
MediaID postgres.ColumnInteger
Price postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type UserMediasTable struct {
userMediasTable
EXCLUDED userMediasTable
}
// AS creates new UserMediasTable with assigned alias
func (a UserMediasTable) AS(alias string) *UserMediasTable {
return newUserMediasTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new UserMediasTable with assigned schema name
func (a UserMediasTable) FromSchema(schemaName string) *UserMediasTable {
return newUserMediasTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new UserMediasTable with assigned table prefix
func (a UserMediasTable) WithPrefix(prefix string) *UserMediasTable {
return newUserMediasTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new UserMediasTable with assigned table suffix
func (a UserMediasTable) WithSuffix(suffix string) *UserMediasTable {
return newUserMediasTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newUserMediasTable(schemaName, tableName, alias string) *UserMediasTable {
return &UserMediasTable{
userMediasTable: newUserMediasTableImpl(schemaName, tableName, alias),
EXCLUDED: newUserMediasTableImpl("", "excluded", ""),
}
}
func newUserMediasTableImpl(schemaName, tableName, alias string) userMediasTable {
var (
IDColumn = postgres.IntegerColumn("id")
UserIDColumn = postgres.IntegerColumn("user_id")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
MediaIDColumn = postgres.IntegerColumn("media_id")
PriceColumn = postgres.IntegerColumn("price")
CreatedAtColumn = postgres.TimestampColumn("created_at")
allColumns = postgres.ColumnList{IDColumn, UserIDColumn, TenantIDColumn, MediaIDColumn, PriceColumn, CreatedAtColumn}
mutableColumns = postgres.ColumnList{UserIDColumn, TenantIDColumn, MediaIDColumn, PriceColumn, CreatedAtColumn}
)
return userMediasTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
UserID: UserIDColumn,
TenantID: TenantIDColumn,
MediaID: MediaIDColumn,
Price: PriceColumn,
CreatedAt: CreatedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -1,93 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var Users = newUsersTable("public", "users", "")
type usersTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
OpenID postgres.ColumnString
UnionID postgres.ColumnString
OAuth postgres.ColumnString
ExpireIn postgres.ColumnTimestamp
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type UsersTable struct {
usersTable
EXCLUDED usersTable
}
// AS creates new UsersTable with assigned alias
func (a UsersTable) AS(alias string) *UsersTable {
return newUsersTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new UsersTable with assigned schema name
func (a UsersTable) FromSchema(schemaName string) *UsersTable {
return newUsersTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new UsersTable with assigned table prefix
func (a UsersTable) WithPrefix(prefix string) *UsersTable {
return newUsersTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new UsersTable with assigned table suffix
func (a UsersTable) WithSuffix(suffix string) *UsersTable {
return newUsersTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newUsersTable(schemaName, tableName, alias string) *UsersTable {
return &UsersTable{
usersTable: newUsersTableImpl(schemaName, tableName, alias),
EXCLUDED: newUsersTableImpl("", "excluded", ""),
}
}
func newUsersTableImpl(schemaName, tableName, alias string) usersTable {
var (
IDColumn = postgres.IntegerColumn("id")
OpenIDColumn = postgres.StringColumn("open_id")
UnionIDColumn = postgres.StringColumn("union_id")
OAuthColumn = postgres.StringColumn("oauth")
ExpireInColumn = postgres.TimestampColumn("expire_in")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
allColumns = postgres.ColumnList{IDColumn, OpenIDColumn, UnionIDColumn, OAuthColumn, ExpireInColumn, CreatedAtColumn, UpdatedAtColumn}
mutableColumns = postgres.ColumnList{OpenIDColumn, UnionIDColumn, OAuthColumn, ExpireInColumn, CreatedAtColumn, UpdatedAtColumn}
)
return usersTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
OpenID: OpenIDColumn,
UnionID: UnionIDColumn,
OAuth: OAuthColumn,
ExpireIn: ExpireInColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -1,84 +0,0 @@
//
// Code generated by go-jet DO NOT EDIT.
//
// WARNING: Changes to this file may cause incorrect behavior
// and will be lost if the code is regenerated
//
package table
import (
"github.com/go-jet/jet/v2/postgres"
)
var UsersTenants = newUsersTenantsTable("public", "users_tenants", "")
type usersTenantsTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
UserID postgres.ColumnInteger
TenantID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type UsersTenantsTable struct {
usersTenantsTable
EXCLUDED usersTenantsTable
}
// AS creates new UsersTenantsTable with assigned alias
func (a UsersTenantsTable) AS(alias string) *UsersTenantsTable {
return newUsersTenantsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new UsersTenantsTable with assigned schema name
func (a UsersTenantsTable) FromSchema(schemaName string) *UsersTenantsTable {
return newUsersTenantsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new UsersTenantsTable with assigned table prefix
func (a UsersTenantsTable) WithPrefix(prefix string) *UsersTenantsTable {
return newUsersTenantsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new UsersTenantsTable with assigned table suffix
func (a UsersTenantsTable) WithSuffix(suffix string) *UsersTenantsTable {
return newUsersTenantsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newUsersTenantsTable(schemaName, tableName, alias string) *UsersTenantsTable {
return &UsersTenantsTable{
usersTenantsTable: newUsersTenantsTableImpl(schemaName, tableName, alias),
EXCLUDED: newUsersTenantsTableImpl("", "excluded", ""),
}
}
func newUsersTenantsTableImpl(schemaName, tableName, alias string) usersTenantsTable {
var (
IDColumn = postgres.IntegerColumn("id")
UserIDColumn = postgres.IntegerColumn("user_id")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
allColumns = postgres.ColumnList{IDColumn, UserIDColumn, TenantIDColumn, CreatedAtColumn}
mutableColumns = postgres.ColumnList{UserIDColumn, TenantIDColumn, CreatedAtColumn}
)
return usersTenantsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
UserID: UserIDColumn,
TenantID: TenantIDColumn,
CreatedAt: CreatedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}