feat: init repo

This commit is contained in:
Rogee
2025-01-09 19:11:01 +08:00
parent b9cc63fe8a
commit 1c7b603769
149 changed files with 20066 additions and 10 deletions

View File

@@ -0,0 +1,44 @@
package database
import (
"context"
"database/sql"
"embed"
"fmt"
"github.com/go-jet/jet/v2/qrm"
)
//go:embed migrations/*
var MigrationFS embed.FS
type CtxDB struct{}
func FromContext(ctx context.Context, db *sql.DB) qrm.DB {
if tx, ok := ctx.Value(CtxDB{}).(*sql.Tx); ok {
return tx
}
return db
}
func Truncate(ctx context.Context, db *sql.DB, tableName ...string) error {
for _, name := range tableName {
sql := fmt.Sprintf("TRUNCATE TABLE %s RESTART IDENTITY", name)
if _, err := db.ExecContext(ctx, sql); err != nil {
return err
}
}
return nil
}
func WrapLike(v string) string {
return "%" + v + "%"
}
func WrapLikeLeft(v string) string {
return "%" + v
}
func WrapLikeRight(v string) string {
return "%" + v
}

View File

@@ -0,0 +1,45 @@
package fields
import (
"database/sql/driver"
"encoding/json"
"errors"
)
// implement sql.Scanner interface
type Json[T any] struct {
Data T `json:",inline"`
}
func ToJson[T any](data T) Json[T] {
return Json[T]{Data: data}
}
func (x *Json[T]) Scan(value interface{}) (err error) {
switch v := value.(type) {
case string:
return json.Unmarshal([]byte(v), &x)
case []byte:
return json.Unmarshal(v, &x)
case *string:
return json.Unmarshal([]byte(*v), &x)
}
return errors.New("Unknown type for ")
}
func (x Json[T]) Value() (driver.Value, error) {
return json.Marshal(x.Data)
}
func (x Json[T]) MarshalJSON() ([]byte, error) {
return json.Marshal(x.Data)
}
func (x *Json[T]) UnmarshalJSON(data []byte) error {
var value T
if err := json.Unmarshal(data, &value); err != nil {
return err
}
x.Data = value
return nil
}

View File

@@ -0,0 +1,408 @@
-- +goose Up
-- +goose StatementBegin
-- River migration 002 [up]
CREATE TYPE river_job_state AS ENUM (
'available',
'cancelled',
'completed',
'discarded',
'pending',
'retryable',
'running',
'scheduled'
);
CREATE TABLE river_job(
-- 8 bytes
id bigserial PRIMARY KEY,
-- 8 bytes (4 bytes + 2 bytes + 2 bytes)
--
-- `state` is kept near the top of the table for operator convenience -- when
-- looking at jobs with `SELECT *` it'll appear first after ID. The other two
-- fields aren't as important but are kept adjacent to `state` for alignment
-- to get an 8-byte block.
state river_job_state NOT NULL DEFAULT 'available',
attempt smallint NOT NULL DEFAULT 0,
max_attempts smallint NOT NULL,
-- 8 bytes each (no alignment needed)
attempted_at timestamptz,
created_at timestamptz NOT NULL DEFAULT NOW(),
finalized_at timestamptz,
scheduled_at timestamptz NOT NULL DEFAULT NOW(),
-- 2 bytes (some wasted padding probably)
priority smallint NOT NULL DEFAULT 1,
-- types stored out-of-band
args jsonb,
attempted_by text[],
errors jsonb[],
kind text NOT NULL,
metadata jsonb NOT NULL DEFAULT '{}',
queue text NOT NULL DEFAULT 'default',
tags varchar(255)[],
CONSTRAINT finalized_or_finalized_at_null CHECK ((state IN ('cancelled', 'completed', 'discarded') AND finalized_at IS NOT NULL) OR finalized_at IS NULL),
CONSTRAINT max_attempts_is_positive CHECK (max_attempts > 0),
CONSTRAINT priority_in_range CHECK (priority >= 1 AND priority <= 4),
CONSTRAINT queue_length CHECK (char_length(queue) > 0 AND char_length(queue) < 128),
CONSTRAINT kind_length CHECK (char_length(kind) > 0 AND char_length(kind) < 128)
);
-- We may want to consider adding another property here after `kind` if it seems
-- like it'd be useful for something.
CREATE INDEX river_job_kind ON river_job USING btree(kind);
CREATE INDEX river_job_state_and_finalized_at_index ON river_job USING btree(state, finalized_at) WHERE finalized_at IS NOT NULL;
CREATE INDEX river_job_prioritized_fetching_index ON river_job USING btree(state, queue, priority, scheduled_at, id);
CREATE INDEX river_job_args_index ON river_job USING GIN(args);
CREATE INDEX river_job_metadata_index ON river_job USING GIN(metadata);
CREATE OR REPLACE FUNCTION river_job_notify()
RETURNS TRIGGER
AS $$
DECLARE
payload json;
BEGIN
IF NEW.state = 'available' THEN
-- Notify will coalesce duplicate notifications within a transaction, so
-- keep these payloads generalized:
payload = json_build_object('queue', NEW.queue);
PERFORM
pg_notify('river_insert', payload::text);
END IF;
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
CREATE TRIGGER river_notify
AFTER INSERT ON river_job
FOR EACH ROW
EXECUTE PROCEDURE river_job_notify();
CREATE UNLOGGED TABLE river_leader(
-- 8 bytes each (no alignment needed)
elected_at timestamptz NOT NULL,
expires_at timestamptz NOT NULL,
-- types stored out-of-band
leader_id text NOT NULL,
name text PRIMARY KEY,
CONSTRAINT name_length CHECK (char_length(name) > 0 AND char_length(name) < 128),
CONSTRAINT leader_id_length CHECK (char_length(leader_id) > 0 AND char_length(leader_id) < 128)
);
-- River migration 003 [up]
ALTER TABLE river_job ALTER COLUMN tags SET DEFAULT '{}';
UPDATE river_job SET tags = '{}' WHERE tags IS NULL;
ALTER TABLE river_job ALTER COLUMN tags SET NOT NULL;
-- River migration 004 [up]
-- The args column never had a NOT NULL constraint or default value at the
-- database level, though we tried to ensure one at the application level.
ALTER TABLE river_job ALTER COLUMN args SET DEFAULT '{}';
UPDATE river_job SET args = '{}' WHERE args IS NULL;
ALTER TABLE river_job ALTER COLUMN args SET NOT NULL;
ALTER TABLE river_job ALTER COLUMN args DROP DEFAULT;
-- The metadata column never had a NOT NULL constraint or default value at the
-- database level, though we tried to ensure one at the application level.
ALTER TABLE river_job ALTER COLUMN metadata SET DEFAULT '{}';
UPDATE river_job SET metadata = '{}' WHERE metadata IS NULL;
ALTER TABLE river_job ALTER COLUMN metadata SET NOT NULL;
-- The 'pending' job state will be used for upcoming functionality:
-- ALTER TYPE river_job_state ADD VALUE IF NOT EXISTS 'pending' AFTER 'discarded';
ALTER TABLE river_job DROP CONSTRAINT finalized_or_finalized_at_null;
ALTER TABLE river_job ADD CONSTRAINT finalized_or_finalized_at_null CHECK (
(finalized_at IS NULL AND state NOT IN ('cancelled', 'completed', 'discarded')) OR
(finalized_at IS NOT NULL AND state IN ('cancelled', 'completed', 'discarded'))
);
DROP TRIGGER river_notify ON river_job;
DROP FUNCTION river_job_notify;
CREATE TABLE river_queue(
name text PRIMARY KEY NOT NULL,
created_at timestamptz NOT NULL DEFAULT NOW(),
metadata jsonb NOT NULL DEFAULT '{}' ::jsonb,
paused_at timestamptz,
updated_at timestamptz NOT NULL
);
ALTER TABLE river_leader
ALTER COLUMN name SET DEFAULT 'default',
DROP CONSTRAINT name_length,
ADD CONSTRAINT name_length CHECK (name = 'default');
-- River migration 005 [up]
--
-- Rebuild the migration table so it's based on `(line, version)`.
--
DO
$body$
BEGIN
-- Tolerate users who may be using their own migration system rather than
-- River's. If they are, they will have skipped version 001 containing
-- `CREATE TABLE river_migration`, so this table won't exist.
IF (SELECT to_regclass('river_migration') IS NOT NULL) THEN
ALTER TABLE river_migration
RENAME TO river_migration_old;
CREATE TABLE river_migration(
line TEXT NOT NULL,
version bigint NOT NULL,
created_at timestamptz NOT NULL DEFAULT NOW(),
CONSTRAINT line_length CHECK (char_length(line) > 0 AND char_length(line) < 128),
CONSTRAINT version_gte_1 CHECK (version >= 1),
PRIMARY KEY (line, version)
);
INSERT INTO river_migration
(created_at, line, version)
SELECT created_at, 'main', version
FROM river_migration_old;
DROP TABLE river_migration_old;
END IF;
END;
$body$
LANGUAGE 'plpgsql';
--
-- Add `river_job.unique_key` and bring up an index on it.
--
-- These statements use `IF NOT EXISTS` to allow users with a `river_job` table
-- of non-trivial size to build the index `CONCURRENTLY` out of band of this
-- migration, then follow by completing the migration.
ALTER TABLE river_job
ADD COLUMN IF NOT EXISTS unique_key bytea;
CREATE UNIQUE INDEX IF NOT EXISTS river_job_kind_unique_key_idx ON river_job (kind, unique_key) WHERE unique_key IS NOT NULL;
--
-- Create `river_client` and derivative.
--
-- This feature hasn't quite yet been implemented, but we're taking advantage of
-- the migration to add the schema early so that we can add it later without an
-- additional migration.
--
CREATE UNLOGGED TABLE river_client (
id text PRIMARY KEY NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
metadata jsonb NOT NULL DEFAULT '{}',
paused_at timestamptz,
updated_at timestamptz NOT NULL,
CONSTRAINT name_length CHECK (char_length(id) > 0 AND char_length(id) < 128)
);
-- Differs from `river_queue` in that it tracks the queue state for a particular
-- active client.
CREATE UNLOGGED TABLE river_client_queue (
river_client_id text NOT NULL REFERENCES river_client (id) ON DELETE CASCADE,
name text NOT NULL,
created_at timestamptz NOT NULL DEFAULT now(),
max_workers bigint NOT NULL DEFAULT 0,
metadata jsonb NOT NULL DEFAULT '{}',
num_jobs_completed bigint NOT NULL DEFAULT 0,
num_jobs_running bigint NOT NULL DEFAULT 0,
updated_at timestamptz NOT NULL,
PRIMARY KEY (river_client_id, name),
CONSTRAINT name_length CHECK (char_length(name) > 0 AND char_length(name) < 128),
CONSTRAINT num_jobs_completed_zero_or_positive CHECK (num_jobs_completed >= 0),
CONSTRAINT num_jobs_running_zero_or_positive CHECK (num_jobs_running >= 0)
);
-- River migration 006 [up]
CREATE OR REPLACE FUNCTION river_job_state_in_bitmask(bitmask BIT(8), state river_job_state)
RETURNS boolean
LANGUAGE SQL
IMMUTABLE
AS $$
SELECT CASE state
WHEN 'available' THEN get_bit(bitmask, 7)
WHEN 'cancelled' THEN get_bit(bitmask, 6)
WHEN 'completed' THEN get_bit(bitmask, 5)
WHEN 'discarded' THEN get_bit(bitmask, 4)
WHEN 'pending' THEN get_bit(bitmask, 3)
WHEN 'retryable' THEN get_bit(bitmask, 2)
WHEN 'running' THEN get_bit(bitmask, 1)
WHEN 'scheduled' THEN get_bit(bitmask, 0)
ELSE 0
END = 1;
$$;
--
-- Add `river_job.unique_states` and bring up an index on it.
--
-- This column may exist already if users manually created the column and index
-- as instructed in the changelog so the index could be created `CONCURRENTLY`.
--
ALTER TABLE river_job ADD COLUMN IF NOT EXISTS unique_states BIT(8);
-- This statement uses `IF NOT EXISTS` to allow users with a `river_job` table
-- of non-trivial size to build the index `CONCURRENTLY` out of band of this
-- migration, then follow by completing the migration.
CREATE UNIQUE INDEX IF NOT EXISTS river_job_unique_idx ON river_job (unique_key)
WHERE unique_key IS NOT NULL
AND unique_states IS NOT NULL
AND river_job_state_in_bitmask(unique_states, state);
-- Remove the old unique index. Users who are actively using the unique jobs
-- feature and who wish to avoid deploy downtime may want od drop this in a
-- subsequent migration once all jobs using the old unique system have been
-- completed (i.e. no more rows with non-null unique_key and null
-- unique_states).
DROP INDEX river_job_kind_unique_key_idx;
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
-- Drop Users Table
-- River migration 006 [down]
--
-- Drop `river_job.unique_states` and its index.
--
DROP INDEX river_job_unique_idx;
ALTER TABLE river_job
DROP COLUMN unique_states;
CREATE UNIQUE INDEX IF NOT EXISTS river_job_kind_unique_key_idx ON river_job (kind, unique_key) WHERE unique_key IS NOT NULL;
--
-- Drop `river_job_state_in_bitmask` function.
--
DROP FUNCTION river_job_state_in_bitmask;
-- River migration 005 [down]
--
-- Revert to migration table based only on `(version)`.
--
-- If any non-main migrations are present, 005 is considered irreversible.
--
DO
$body$
BEGIN
-- Tolerate users who may be using their own migration system rather than
-- River's. If they are, they will have skipped version 001 containing
-- `CREATE TABLE river_migration`, so this table won't exist.
IF (SELECT to_regclass('river_migration') IS NOT NULL) THEN
IF EXISTS (
SELECT *
FROM river_migration
WHERE line <> 'main'
) THEN
RAISE EXCEPTION 'Found non-main migration lines in the database; version 005 migration is irreversible because it would result in loss of migration information.';
END IF;
ALTER TABLE river_migration
RENAME TO river_migration_old;
CREATE TABLE river_migration(
id bigserial PRIMARY KEY,
created_at timestamptz NOT NULL DEFAULT NOW(),
version bigint NOT NULL,
CONSTRAINT version CHECK (version >= 1)
);
CREATE UNIQUE INDEX ON river_migration USING btree(version);
INSERT INTO river_migration
(created_at, version)
SELECT created_at, version
FROM river_migration_old;
DROP TABLE river_migration_old;
END IF;
END;
$body$
LANGUAGE 'plpgsql';
--
-- Drop `river_job.unique_key`.
--
ALTER TABLE river_job
DROP COLUMN unique_key;
--
-- Drop `river_client` and derivative.
--
DROP TABLE river_client_queue;
DROP TABLE river_client;
-- River migration 004 [down]
ALTER TABLE river_job ALTER COLUMN args DROP NOT NULL;
ALTER TABLE river_job ALTER COLUMN metadata DROP NOT NULL;
ALTER TABLE river_job ALTER COLUMN metadata DROP DEFAULT;
-- It is not possible to safely remove 'pending' from the river_job_state enum,
-- so leave it in place.
ALTER TABLE river_job DROP CONSTRAINT finalized_or_finalized_at_null;
ALTER TABLE river_job ADD CONSTRAINT finalized_or_finalized_at_null CHECK (
(state IN ('cancelled', 'completed', 'discarded') AND finalized_at IS NOT NULL) OR finalized_at IS NULL
);
CREATE OR REPLACE FUNCTION river_job_notify()
RETURNS TRIGGER
AS $$
DECLARE
payload json;
BEGIN
IF NEW.state = 'available' THEN
-- Notify will coalesce duplicate notifications within a transaction, so
-- keep these payloads generalized:
payload = json_build_object('queue', NEW.queue);
PERFORM
pg_notify('river_insert', payload::text);
END IF;
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
CREATE TRIGGER river_notify
AFTER INSERT ON river_job
FOR EACH ROW
EXECUTE PROCEDURE river_job_notify();
DROP TABLE river_queue;
ALTER TABLE river_leader
ALTER COLUMN name DROP DEFAULT,
DROP CONSTRAINT name_length,
ADD CONSTRAINT name_length CHECK (char_length(name) > 0 AND char_length(name) < 128);
-- River migration 003 [down]
ALTER TABLE river_job ALTER COLUMN tags DROP NOT NULL,
ALTER COLUMN tags DROP DEFAULT;
-- River migration 002 [down]
DROP TABLE river_job;
DROP FUNCTION river_job_notify;
DROP TYPE river_job_state;
DROP TABLE river_leader;
-- +goose StatementEnd

View File

@@ -0,0 +1,53 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE
users (
id SERIAL8 PRIMARY KEY,
created_at timestamp NOT NULL default now(),
updated_at timestamp NOT NULL default now(),
deleted_at timestamp,
status INT2 NOT NULL default 0,
email VARCHAR(128) NOT NULL UNIQUE,
phone VARCHAR(32) NOT NULL UNIQUE,
username VARCHAR(128) NOT NULL UNIQUE,
nickname VARCHAR(128) ,
password VARCHAR(128) NOT NULL,
age INT2 NOT NULL default 0,
sex INT2 NOT NULL default 0,
avatar VARCHAR(128)
);
-- index on email phone username
CREATE INDEX idx_users_email ON users(email);
CREATE INDEX idx_users_phone ON users(phone);
CREATE INDEX idx_users_username ON users(username);
CREATE TABLE
user_oauths (
id SERIAL8 PRIMARY KEY,
created_at timestamp NOT NULL default now(),
updated_at timestamp NOT NULL default now(),
deleted_at timestamp,
channel INT2 NOT NULL,
user_id INT8 NOT NULL,
union_id VARCHAR(128),
open_id VARCHAR(128) NOT NULL UNIQUE,
access_key VARCHAR(256) NOT NULL default '',
access_token VARCHAR(256) NOT NULL default '',
refresh_token VARCHAR(256) NOT NULL default '',
expire_at timestamp NOT NULL,
meta jsonb default '{}'::jsonb
);
-- index on channel user_id open_id
CREATE INDEX idx_user_oauths_channel ON user_oauths(channel);
CREATE INDEX idx_user_oauths_user_id ON user_oauths(user_id);
CREATE INDEX idx_user_oauths_open_id ON user_oauths(open_id);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE users;
DROP TABLE user_oauths;
-- +goose StatementEnd

View File

@@ -0,0 +1,55 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE
tenants (
id SERIAL8 PRIMARY KEY,
created_at timestamp NOT NULL default now(),
updated_at timestamp NOT NULL default now(),
expired_at timestamp NOT NULL,
created_by_user_id INT8 NOT NULL,
name VARCHAR(128) NOT NULL,
slug VARCHAR(128) NOT NULL UNIQUE,
description VARCHAR(128)
);
-- index on name slug
CREATE INDEX idx_tenants_name ON tenants(name);
CREATE INDEX idx_tenants_slug ON tenants(slug);
CREATE TABLE
tenant_users (
id SERIAL8 PRIMARY KEY,
created_at timestamp NOT NULL default now (),
updated_at timestamp NOT NULL default now (),
deleted_at timestamp,
tenant_id INT8 NOT NULL,
user_id INT8 NOT NULL,
status INT2 NOT NULL default 0,
role INT2 NOT NULL default 0
);
-- indexes
CREATE INDEX idx_tenant_users_tenant_id ON tenant_users(tenant_id);
CREATE INDEX idx_tenant_users_user_id ON tenant_users(user_id);
CREATE INDEX idx_tenant_users_role ON tenant_users(role);
-- create tenant user balance
CREATE TABLE
tenant_user_balances (
id SERIAL8 PRIMARY KEY,
created_at timestamp NOT NULL default now (),
updated_at timestamp NOT NULL default now (),
tenant_id INT8 NOT NULL,
user_id INT8 NOT NULL,
balance INT8 NOT NULL default 0
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE tenants;
DROP TABLE tenant_users;
-- +goose StatementEnd

View File

@@ -0,0 +1,38 @@
-- +goose Up
-- +goose StatementBegin
-- create table orders
CREATE TABLE
orders (
id SERIAL8 PRIMARY KEY,
created_at timestamp NOT NULL default now(),
updated_at timestamp NOT NULL default now(),
deleted_at timestamp,
tenant_id INT8 NOT NULL,
user_id INT8 NOT NULL,
type INT2 NOT NULL default 0,
status INT2 NOT NULL default 0,
order_serial VARCHAR(64) NOT NULL UNIQUE,
remote_order_serial VARCHAR(256) NOT NULL UNIQUE,
refund_serial VARCHAR(64) NOT NULL UNIQUE,
remote_refund_serial VARCHAR(256) NOT NULL UNIQUE,
amount INT8 NOT NULL default 0,
currency VARCHAR(32) NOT NULL default 'CNY',
description VARCHAR(256),
meta jsonb default '{}'::jsonb
);
-- create indexes
CREATE INDEX idx_orders_tenant_id ON orders(tenant_id);
CREATE INDEX idx_orders_user_id ON orders(user_id);
CREATE INDEX idx_orders_order_serial ON orders(order_serial);
CREATE INDEX idx_orders_remote_order_serial ON orders(remote_order_serial);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE orders;
-- +goose StatementEnd

View File

@@ -0,0 +1,33 @@
-- +goose Up
-- +goose StatementBegin
-- create posts table
CREATE TABLE
posts (
id SERIAL8 PRIMARY KEY,
created_at timestamp NOT NULL default now(),
updated_at timestamp NOT NULL default now(),
deleted_at timestamp,
tenant_id INT8 NOT NULL,
user_id INT8 NOT NULL,
hash_id VARCHAR(128) NOT NULL,
title VARCHAR(128) NOT NULL,
description VARCHAR(256) NOT NULL,
poster VARCHAR(128) NOT NULL,
content TEXT NOT NULL,
stage INT2 NOT NULL default 0,
status INT2 NOT NULL default 0,
price INT8 NOT NULL default 0,
discount INT2 NOT NULL default 100,
views INT8 NOT NULL default 0,
likes INT8 NOT NULL default 0,
meta jsonb default '{}'::jsonb,
assets jsonb default '{}'::jsonb
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE posts;
-- +goose StatementEnd

View File

View File

@@ -0,0 +1,30 @@
//
// 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 enum
import "github.com/go-jet/jet/v2/postgres"
var RiverJobState = &struct {
Available postgres.StringExpression
Cancelled postgres.StringExpression
Completed postgres.StringExpression
Discarded postgres.StringExpression
Pending postgres.StringExpression
Retryable postgres.StringExpression
Running postgres.StringExpression
Scheduled postgres.StringExpression
}{
Available: postgres.NewEnumValue("available"),
Cancelled: postgres.NewEnumValue("cancelled"),
Completed: postgres.NewEnumValue("completed"),
Discarded: postgres.NewEnumValue("discarded"),
Pending: postgres.NewEnumValue("pending"),
Retryable: postgres.NewEnumValue("retryable"),
Running: postgres.NewEnumValue("running"),
Scheduled: postgres.NewEnumValue("scheduled"),
}

View File

@@ -0,0 +1,31 @@
//
// 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 Orders struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
Type int16 `json:"type"`
Status int16 `json:"status"`
OrderSerial string `json:"order_serial"`
RemoteOrderSerial string `json:"remote_order_serial"`
RefundSerial string `json:"refund_serial"`
RemoteRefundSerial string `json:"remote_refund_serial"`
Amount int64 `json:"amount"`
Currency string `json:"currency"`
Description *string `json:"description"`
Meta *string `json:"meta"`
}

View File

@@ -0,0 +1,34 @@
//
// 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 Posts struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
HashID string `json:"hash_id"`
Title string `json:"title"`
Description string `json:"description"`
Poster string `json:"poster"`
Content string `json:"content"`
Stage int16 `json:"stage"`
Status int16 `json:"status"`
Price int64 `json:"price"`
Discount int16 `json:"discount"`
Views int64 `json:"views"`
Likes int64 `json:"likes"`
Meta *string `json:"meta"`
Assets *string `json:"assets"`
}

View File

@@ -0,0 +1,73 @@
//
// 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 "errors"
type RiverJobState string
const (
RiverJobState_Available RiverJobState = "available"
RiverJobState_Cancelled RiverJobState = "cancelled"
RiverJobState_Completed RiverJobState = "completed"
RiverJobState_Discarded RiverJobState = "discarded"
RiverJobState_Pending RiverJobState = "pending"
RiverJobState_Retryable RiverJobState = "retryable"
RiverJobState_Running RiverJobState = "running"
RiverJobState_Scheduled RiverJobState = "scheduled"
)
var RiverJobStateAllValues = []RiverJobState{
RiverJobState_Available,
RiverJobState_Cancelled,
RiverJobState_Completed,
RiverJobState_Discarded,
RiverJobState_Pending,
RiverJobState_Retryable,
RiverJobState_Running,
RiverJobState_Scheduled,
}
func (e *RiverJobState) Scan(value interface{}) error {
var enumValue string
switch val := value.(type) {
case string:
enumValue = val
case []byte:
enumValue = string(val)
default:
return errors.New("jet: Invalid scan value for AllTypesEnum enum. Enum value has to be of type string or []byte")
}
switch enumValue {
case "available":
*e = RiverJobState_Available
case "cancelled":
*e = RiverJobState_Cancelled
case "completed":
*e = RiverJobState_Completed
case "discarded":
*e = RiverJobState_Discarded
case "pending":
*e = RiverJobState_Pending
case "retryable":
*e = RiverJobState_Retryable
case "running":
*e = RiverJobState_Running
case "scheduled":
*e = RiverJobState_Scheduled
default:
return errors.New("jet: Invalid scan value '" + enumValue + "' for RiverJobState enum")
}
return nil
}
func (e RiverJobState) String() string {
return string(e)
}

View File

@@ -0,0 +1,21 @@
//
// 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 TenantUserBalances struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
Balance int64 `json:"balance"`
}

View File

@@ -0,0 +1,23 @@
//
// 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 TenantUsers struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
TenantID int64 `json:"tenant_id"`
UserID int64 `json:"user_id"`
Status int16 `json:"status"`
Role int16 `json:"role"`
}

View File

@@ -0,0 +1,23 @@
//
// 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" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
ExpiredAt time.Time `json:"expired_at"`
CreatedByUserID int64 `json:"created_by_user_id"`
Name string `json:"name"`
Slug string `json:"slug"`
Description *string `json:"description"`
}

View File

@@ -0,0 +1,28 @@
//
// 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 UserOauths struct {
ID int64 `sql:"primary_key" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
Channel int16 `json:"channel"`
UserID int64 `json:"user_id"`
UnionID *string `json:"union_id"`
OpenID string `json:"open_id"`
AccessKey string `json:"access_key"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpireAt time.Time `json:"expire_at"`
Meta *string `json:"meta"`
}

View File

@@ -0,0 +1,28 @@
//
// 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" json:"id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
Status int16 `json:"status"`
Email string `json:"email"`
Phone string `json:"phone"`
Username string `json:"username"`
Nickname *string `json:"nickname"`
Password string `json:"password"`
Age int16 `json:"age"`
Sex int16 `json:"sex"`
Avatar *string `json:"avatar"`
}

View File

@@ -0,0 +1,84 @@
//
// 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

@@ -0,0 +1,120 @@
//
// 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 Orders = newOrdersTable("public", "orders", "")
type ordersTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
DeletedAt postgres.ColumnTimestamp
TenantID postgres.ColumnInteger
UserID postgres.ColumnInteger
Type postgres.ColumnInteger
Status postgres.ColumnInteger
OrderSerial postgres.ColumnString
RemoteOrderSerial postgres.ColumnString
RefundSerial postgres.ColumnString
RemoteRefundSerial postgres.ColumnString
Amount postgres.ColumnInteger
Currency postgres.ColumnString
Description postgres.ColumnString
Meta postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type OrdersTable struct {
ordersTable
EXCLUDED ordersTable
}
// AS creates new OrdersTable with assigned alias
func (a OrdersTable) AS(alias string) *OrdersTable {
return newOrdersTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new OrdersTable with assigned schema name
func (a OrdersTable) FromSchema(schemaName string) *OrdersTable {
return newOrdersTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new OrdersTable with assigned table prefix
func (a OrdersTable) WithPrefix(prefix string) *OrdersTable {
return newOrdersTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new OrdersTable with assigned table suffix
func (a OrdersTable) WithSuffix(suffix string) *OrdersTable {
return newOrdersTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newOrdersTable(schemaName, tableName, alias string) *OrdersTable {
return &OrdersTable{
ordersTable: newOrdersTableImpl(schemaName, tableName, alias),
EXCLUDED: newOrdersTableImpl("", "excluded", ""),
}
}
func newOrdersTableImpl(schemaName, tableName, alias string) ordersTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
UserIDColumn = postgres.IntegerColumn("user_id")
TypeColumn = postgres.IntegerColumn("type")
StatusColumn = postgres.IntegerColumn("status")
OrderSerialColumn = postgres.StringColumn("order_serial")
RemoteOrderSerialColumn = postgres.StringColumn("remote_order_serial")
RefundSerialColumn = postgres.StringColumn("refund_serial")
RemoteRefundSerialColumn = postgres.StringColumn("remote_refund_serial")
AmountColumn = postgres.IntegerColumn("amount")
CurrencyColumn = postgres.StringColumn("currency")
DescriptionColumn = postgres.StringColumn("description")
MetaColumn = postgres.StringColumn("meta")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, TypeColumn, StatusColumn, OrderSerialColumn, RemoteOrderSerialColumn, RefundSerialColumn, RemoteRefundSerialColumn, AmountColumn, CurrencyColumn, DescriptionColumn, MetaColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, TypeColumn, StatusColumn, OrderSerialColumn, RemoteOrderSerialColumn, RefundSerialColumn, RemoteRefundSerialColumn, AmountColumn, CurrencyColumn, DescriptionColumn, MetaColumn}
)
return ordersTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
DeletedAt: DeletedAtColumn,
TenantID: TenantIDColumn,
UserID: UserIDColumn,
Type: TypeColumn,
Status: StatusColumn,
OrderSerial: OrderSerialColumn,
RemoteOrderSerial: RemoteOrderSerialColumn,
RefundSerial: RefundSerialColumn,
RemoteRefundSerial: RemoteRefundSerialColumn,
Amount: AmountColumn,
Currency: CurrencyColumn,
Description: DescriptionColumn,
Meta: MetaColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,129 @@
//
// 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 Posts = newPostsTable("public", "posts", "")
type postsTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
DeletedAt postgres.ColumnTimestamp
TenantID postgres.ColumnInteger
UserID postgres.ColumnInteger
HashID postgres.ColumnString
Title postgres.ColumnString
Description postgres.ColumnString
Poster postgres.ColumnString
Content postgres.ColumnString
Stage postgres.ColumnInteger
Status postgres.ColumnInteger
Price postgres.ColumnInteger
Discount postgres.ColumnInteger
Views postgres.ColumnInteger
Likes postgres.ColumnInteger
Meta postgres.ColumnString
Assets postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type PostsTable struct {
postsTable
EXCLUDED postsTable
}
// AS creates new PostsTable with assigned alias
func (a PostsTable) AS(alias string) *PostsTable {
return newPostsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new PostsTable with assigned schema name
func (a PostsTable) FromSchema(schemaName string) *PostsTable {
return newPostsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new PostsTable with assigned table prefix
func (a PostsTable) WithPrefix(prefix string) *PostsTable {
return newPostsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new PostsTable with assigned table suffix
func (a PostsTable) WithSuffix(suffix string) *PostsTable {
return newPostsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newPostsTable(schemaName, tableName, alias string) *PostsTable {
return &PostsTable{
postsTable: newPostsTableImpl(schemaName, tableName, alias),
EXCLUDED: newPostsTableImpl("", "excluded", ""),
}
}
func newPostsTableImpl(schemaName, tableName, alias string) postsTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
UserIDColumn = postgres.IntegerColumn("user_id")
HashIDColumn = postgres.StringColumn("hash_id")
TitleColumn = postgres.StringColumn("title")
DescriptionColumn = postgres.StringColumn("description")
PosterColumn = postgres.StringColumn("poster")
ContentColumn = postgres.StringColumn("content")
StageColumn = postgres.IntegerColumn("stage")
StatusColumn = postgres.IntegerColumn("status")
PriceColumn = postgres.IntegerColumn("price")
DiscountColumn = postgres.IntegerColumn("discount")
ViewsColumn = postgres.IntegerColumn("views")
LikesColumn = postgres.IntegerColumn("likes")
MetaColumn = postgres.StringColumn("meta")
AssetsColumn = postgres.StringColumn("assets")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, HashIDColumn, TitleColumn, DescriptionColumn, PosterColumn, ContentColumn, StageColumn, StatusColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, MetaColumn, AssetsColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, HashIDColumn, TitleColumn, DescriptionColumn, PosterColumn, ContentColumn, StageColumn, StatusColumn, PriceColumn, DiscountColumn, ViewsColumn, LikesColumn, MetaColumn, AssetsColumn}
)
return postsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
DeletedAt: DeletedAtColumn,
TenantID: TenantIDColumn,
UserID: UserIDColumn,
HashID: HashIDColumn,
Title: TitleColumn,
Description: DescriptionColumn,
Poster: PosterColumn,
Content: ContentColumn,
Stage: StageColumn,
Status: StatusColumn,
Price: PriceColumn,
Discount: DiscountColumn,
Views: ViewsColumn,
Likes: LikesColumn,
Meta: MetaColumn,
Assets: AssetsColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,87 @@
//
// 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 RiverClient = newRiverClientTable("public", "river_client", "")
type riverClientTable struct {
postgres.Table
// Columns
ID postgres.ColumnString
CreatedAt postgres.ColumnTimestampz
Metadata postgres.ColumnString
PausedAt postgres.ColumnTimestampz
UpdatedAt postgres.ColumnTimestampz
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type RiverClientTable struct {
riverClientTable
EXCLUDED riverClientTable
}
// AS creates new RiverClientTable with assigned alias
func (a RiverClientTable) AS(alias string) *RiverClientTable {
return newRiverClientTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new RiverClientTable with assigned schema name
func (a RiverClientTable) FromSchema(schemaName string) *RiverClientTable {
return newRiverClientTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new RiverClientTable with assigned table prefix
func (a RiverClientTable) WithPrefix(prefix string) *RiverClientTable {
return newRiverClientTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new RiverClientTable with assigned table suffix
func (a RiverClientTable) WithSuffix(suffix string) *RiverClientTable {
return newRiverClientTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newRiverClientTable(schemaName, tableName, alias string) *RiverClientTable {
return &RiverClientTable{
riverClientTable: newRiverClientTableImpl(schemaName, tableName, alias),
EXCLUDED: newRiverClientTableImpl("", "excluded", ""),
}
}
func newRiverClientTableImpl(schemaName, tableName, alias string) riverClientTable {
var (
IDColumn = postgres.StringColumn("id")
CreatedAtColumn = postgres.TimestampzColumn("created_at")
MetadataColumn = postgres.StringColumn("metadata")
PausedAtColumn = postgres.TimestampzColumn("paused_at")
UpdatedAtColumn = postgres.TimestampzColumn("updated_at")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, MetadataColumn, PausedAtColumn, UpdatedAtColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, MetadataColumn, PausedAtColumn, UpdatedAtColumn}
)
return riverClientTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
Metadata: MetadataColumn,
PausedAt: PausedAtColumn,
UpdatedAt: UpdatedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,96 @@
//
// 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 RiverClientQueue = newRiverClientQueueTable("public", "river_client_queue", "")
type riverClientQueueTable struct {
postgres.Table
// Columns
RiverClientID postgres.ColumnString
Name postgres.ColumnString
CreatedAt postgres.ColumnTimestampz
MaxWorkers postgres.ColumnInteger
Metadata postgres.ColumnString
NumJobsCompleted postgres.ColumnInteger
NumJobsRunning postgres.ColumnInteger
UpdatedAt postgres.ColumnTimestampz
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type RiverClientQueueTable struct {
riverClientQueueTable
EXCLUDED riverClientQueueTable
}
// AS creates new RiverClientQueueTable with assigned alias
func (a RiverClientQueueTable) AS(alias string) *RiverClientQueueTable {
return newRiverClientQueueTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new RiverClientQueueTable with assigned schema name
func (a RiverClientQueueTable) FromSchema(schemaName string) *RiverClientQueueTable {
return newRiverClientQueueTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new RiverClientQueueTable with assigned table prefix
func (a RiverClientQueueTable) WithPrefix(prefix string) *RiverClientQueueTable {
return newRiverClientQueueTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new RiverClientQueueTable with assigned table suffix
func (a RiverClientQueueTable) WithSuffix(suffix string) *RiverClientQueueTable {
return newRiverClientQueueTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newRiverClientQueueTable(schemaName, tableName, alias string) *RiverClientQueueTable {
return &RiverClientQueueTable{
riverClientQueueTable: newRiverClientQueueTableImpl(schemaName, tableName, alias),
EXCLUDED: newRiverClientQueueTableImpl("", "excluded", ""),
}
}
func newRiverClientQueueTableImpl(schemaName, tableName, alias string) riverClientQueueTable {
var (
RiverClientIDColumn = postgres.StringColumn("river_client_id")
NameColumn = postgres.StringColumn("name")
CreatedAtColumn = postgres.TimestampzColumn("created_at")
MaxWorkersColumn = postgres.IntegerColumn("max_workers")
MetadataColumn = postgres.StringColumn("metadata")
NumJobsCompletedColumn = postgres.IntegerColumn("num_jobs_completed")
NumJobsRunningColumn = postgres.IntegerColumn("num_jobs_running")
UpdatedAtColumn = postgres.TimestampzColumn("updated_at")
allColumns = postgres.ColumnList{RiverClientIDColumn, NameColumn, CreatedAtColumn, MaxWorkersColumn, MetadataColumn, NumJobsCompletedColumn, NumJobsRunningColumn, UpdatedAtColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, MaxWorkersColumn, MetadataColumn, NumJobsCompletedColumn, NumJobsRunningColumn, UpdatedAtColumn}
)
return riverClientQueueTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
RiverClientID: RiverClientIDColumn,
Name: NameColumn,
CreatedAt: CreatedAtColumn,
MaxWorkers: MaxWorkersColumn,
Metadata: MetadataColumn,
NumJobsCompleted: NumJobsCompletedColumn,
NumJobsRunning: NumJobsRunningColumn,
UpdatedAt: UpdatedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,126 @@
//
// 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 RiverJob = newRiverJobTable("public", "river_job", "")
type riverJobTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
State postgres.ColumnString
Attempt postgres.ColumnInteger
MaxAttempts postgres.ColumnInteger
AttemptedAt postgres.ColumnTimestampz
CreatedAt postgres.ColumnTimestampz
FinalizedAt postgres.ColumnTimestampz
ScheduledAt postgres.ColumnTimestampz
Priority postgres.ColumnInteger
Args postgres.ColumnString
AttemptedBy postgres.ColumnString
Errors postgres.ColumnString
Kind postgres.ColumnString
Metadata postgres.ColumnString
Queue postgres.ColumnString
Tags postgres.ColumnString
UniqueKey postgres.ColumnString
UniqueStates postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type RiverJobTable struct {
riverJobTable
EXCLUDED riverJobTable
}
// AS creates new RiverJobTable with assigned alias
func (a RiverJobTable) AS(alias string) *RiverJobTable {
return newRiverJobTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new RiverJobTable with assigned schema name
func (a RiverJobTable) FromSchema(schemaName string) *RiverJobTable {
return newRiverJobTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new RiverJobTable with assigned table prefix
func (a RiverJobTable) WithPrefix(prefix string) *RiverJobTable {
return newRiverJobTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new RiverJobTable with assigned table suffix
func (a RiverJobTable) WithSuffix(suffix string) *RiverJobTable {
return newRiverJobTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newRiverJobTable(schemaName, tableName, alias string) *RiverJobTable {
return &RiverJobTable{
riverJobTable: newRiverJobTableImpl(schemaName, tableName, alias),
EXCLUDED: newRiverJobTableImpl("", "excluded", ""),
}
}
func newRiverJobTableImpl(schemaName, tableName, alias string) riverJobTable {
var (
IDColumn = postgres.IntegerColumn("id")
StateColumn = postgres.StringColumn("state")
AttemptColumn = postgres.IntegerColumn("attempt")
MaxAttemptsColumn = postgres.IntegerColumn("max_attempts")
AttemptedAtColumn = postgres.TimestampzColumn("attempted_at")
CreatedAtColumn = postgres.TimestampzColumn("created_at")
FinalizedAtColumn = postgres.TimestampzColumn("finalized_at")
ScheduledAtColumn = postgres.TimestampzColumn("scheduled_at")
PriorityColumn = postgres.IntegerColumn("priority")
ArgsColumn = postgres.StringColumn("args")
AttemptedByColumn = postgres.StringColumn("attempted_by")
ErrorsColumn = postgres.StringColumn("errors")
KindColumn = postgres.StringColumn("kind")
MetadataColumn = postgres.StringColumn("metadata")
QueueColumn = postgres.StringColumn("queue")
TagsColumn = postgres.StringColumn("tags")
UniqueKeyColumn = postgres.StringColumn("unique_key")
UniqueStatesColumn = postgres.StringColumn("unique_states")
allColumns = postgres.ColumnList{IDColumn, StateColumn, AttemptColumn, MaxAttemptsColumn, AttemptedAtColumn, CreatedAtColumn, FinalizedAtColumn, ScheduledAtColumn, PriorityColumn, ArgsColumn, AttemptedByColumn, ErrorsColumn, KindColumn, MetadataColumn, QueueColumn, TagsColumn, UniqueKeyColumn, UniqueStatesColumn}
mutableColumns = postgres.ColumnList{StateColumn, AttemptColumn, MaxAttemptsColumn, AttemptedAtColumn, CreatedAtColumn, FinalizedAtColumn, ScheduledAtColumn, PriorityColumn, ArgsColumn, AttemptedByColumn, ErrorsColumn, KindColumn, MetadataColumn, QueueColumn, TagsColumn, UniqueKeyColumn, UniqueStatesColumn}
)
return riverJobTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
State: StateColumn,
Attempt: AttemptColumn,
MaxAttempts: MaxAttemptsColumn,
AttemptedAt: AttemptedAtColumn,
CreatedAt: CreatedAtColumn,
FinalizedAt: FinalizedAtColumn,
ScheduledAt: ScheduledAtColumn,
Priority: PriorityColumn,
Args: ArgsColumn,
AttemptedBy: AttemptedByColumn,
Errors: ErrorsColumn,
Kind: KindColumn,
Metadata: MetadataColumn,
Queue: QueueColumn,
Tags: TagsColumn,
UniqueKey: UniqueKeyColumn,
UniqueStates: UniqueStatesColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,84 @@
//
// 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 RiverLeader = newRiverLeaderTable("public", "river_leader", "")
type riverLeaderTable struct {
postgres.Table
// Columns
ElectedAt postgres.ColumnTimestampz
ExpiresAt postgres.ColumnTimestampz
LeaderID postgres.ColumnString
Name postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type RiverLeaderTable struct {
riverLeaderTable
EXCLUDED riverLeaderTable
}
// AS creates new RiverLeaderTable with assigned alias
func (a RiverLeaderTable) AS(alias string) *RiverLeaderTable {
return newRiverLeaderTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new RiverLeaderTable with assigned schema name
func (a RiverLeaderTable) FromSchema(schemaName string) *RiverLeaderTable {
return newRiverLeaderTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new RiverLeaderTable with assigned table prefix
func (a RiverLeaderTable) WithPrefix(prefix string) *RiverLeaderTable {
return newRiverLeaderTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new RiverLeaderTable with assigned table suffix
func (a RiverLeaderTable) WithSuffix(suffix string) *RiverLeaderTable {
return newRiverLeaderTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newRiverLeaderTable(schemaName, tableName, alias string) *RiverLeaderTable {
return &RiverLeaderTable{
riverLeaderTable: newRiverLeaderTableImpl(schemaName, tableName, alias),
EXCLUDED: newRiverLeaderTableImpl("", "excluded", ""),
}
}
func newRiverLeaderTableImpl(schemaName, tableName, alias string) riverLeaderTable {
var (
ElectedAtColumn = postgres.TimestampzColumn("elected_at")
ExpiresAtColumn = postgres.TimestampzColumn("expires_at")
LeaderIDColumn = postgres.StringColumn("leader_id")
NameColumn = postgres.StringColumn("name")
allColumns = postgres.ColumnList{ElectedAtColumn, ExpiresAtColumn, LeaderIDColumn, NameColumn}
mutableColumns = postgres.ColumnList{ElectedAtColumn, ExpiresAtColumn, LeaderIDColumn}
)
return riverLeaderTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ElectedAt: ElectedAtColumn,
ExpiresAt: ExpiresAtColumn,
LeaderID: LeaderIDColumn,
Name: NameColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,87 @@
//
// 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 RiverQueue = newRiverQueueTable("public", "river_queue", "")
type riverQueueTable struct {
postgres.Table
// Columns
Name postgres.ColumnString
CreatedAt postgres.ColumnTimestampz
Metadata postgres.ColumnString
PausedAt postgres.ColumnTimestampz
UpdatedAt postgres.ColumnTimestampz
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type RiverQueueTable struct {
riverQueueTable
EXCLUDED riverQueueTable
}
// AS creates new RiverQueueTable with assigned alias
func (a RiverQueueTable) AS(alias string) *RiverQueueTable {
return newRiverQueueTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new RiverQueueTable with assigned schema name
func (a RiverQueueTable) FromSchema(schemaName string) *RiverQueueTable {
return newRiverQueueTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new RiverQueueTable with assigned table prefix
func (a RiverQueueTable) WithPrefix(prefix string) *RiverQueueTable {
return newRiverQueueTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new RiverQueueTable with assigned table suffix
func (a RiverQueueTable) WithSuffix(suffix string) *RiverQueueTable {
return newRiverQueueTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newRiverQueueTable(schemaName, tableName, alias string) *RiverQueueTable {
return &RiverQueueTable{
riverQueueTable: newRiverQueueTableImpl(schemaName, tableName, alias),
EXCLUDED: newRiverQueueTableImpl("", "excluded", ""),
}
}
func newRiverQueueTableImpl(schemaName, tableName, alias string) riverQueueTable {
var (
NameColumn = postgres.StringColumn("name")
CreatedAtColumn = postgres.TimestampzColumn("created_at")
MetadataColumn = postgres.StringColumn("metadata")
PausedAtColumn = postgres.TimestampzColumn("paused_at")
UpdatedAtColumn = postgres.TimestampzColumn("updated_at")
allColumns = postgres.ColumnList{NameColumn, CreatedAtColumn, MetadataColumn, PausedAtColumn, UpdatedAtColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, MetadataColumn, PausedAtColumn, UpdatedAtColumn}
)
return riverQueueTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
Name: NameColumn,
CreatedAt: CreatedAtColumn,
Metadata: MetadataColumn,
PausedAt: PausedAtColumn,
UpdatedAt: UpdatedAtColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,26 @@
//
// 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) {
Migrations = Migrations.FromSchema(schema)
Orders = Orders.FromSchema(schema)
Posts = Posts.FromSchema(schema)
RiverClient = RiverClient.FromSchema(schema)
RiverClientQueue = RiverClientQueue.FromSchema(schema)
RiverJob = RiverJob.FromSchema(schema)
RiverLeader = RiverLeader.FromSchema(schema)
RiverQueue = RiverQueue.FromSchema(schema)
TenantUserBalances = TenantUserBalances.FromSchema(schema)
TenantUsers = TenantUsers.FromSchema(schema)
Tenants = Tenants.FromSchema(schema)
UserOauths = UserOauths.FromSchema(schema)
Users = Users.FromSchema(schema)
}

View File

@@ -0,0 +1,90 @@
//
// 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
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
TenantID postgres.ColumnInteger
UserID 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")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
UserIDColumn = postgres.IntegerColumn("user_id")
BalanceColumn = postgres.IntegerColumn("balance")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, BalanceColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, TenantIDColumn, UserIDColumn, BalanceColumn}
)
return tenantUserBalancesTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
TenantID: TenantIDColumn,
UserID: UserIDColumn,
Balance: BalanceColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,96 @@
//
// 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 TenantUsers = newTenantUsersTable("public", "tenant_users", "")
type tenantUsersTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
DeletedAt postgres.ColumnTimestamp
TenantID postgres.ColumnInteger
UserID postgres.ColumnInteger
Status postgres.ColumnInteger
Role postgres.ColumnInteger
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type TenantUsersTable struct {
tenantUsersTable
EXCLUDED tenantUsersTable
}
// AS creates new TenantUsersTable with assigned alias
func (a TenantUsersTable) AS(alias string) *TenantUsersTable {
return newTenantUsersTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new TenantUsersTable with assigned schema name
func (a TenantUsersTable) FromSchema(schemaName string) *TenantUsersTable {
return newTenantUsersTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new TenantUsersTable with assigned table prefix
func (a TenantUsersTable) WithPrefix(prefix string) *TenantUsersTable {
return newTenantUsersTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new TenantUsersTable with assigned table suffix
func (a TenantUsersTable) WithSuffix(suffix string) *TenantUsersTable {
return newTenantUsersTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newTenantUsersTable(schemaName, tableName, alias string) *TenantUsersTable {
return &TenantUsersTable{
tenantUsersTable: newTenantUsersTableImpl(schemaName, tableName, alias),
EXCLUDED: newTenantUsersTableImpl("", "excluded", ""),
}
}
func newTenantUsersTableImpl(schemaName, tableName, alias string) tenantUsersTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
TenantIDColumn = postgres.IntegerColumn("tenant_id")
UserIDColumn = postgres.IntegerColumn("user_id")
StatusColumn = postgres.IntegerColumn("status")
RoleColumn = postgres.IntegerColumn("role")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, StatusColumn, RoleColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, TenantIDColumn, UserIDColumn, StatusColumn, RoleColumn}
)
return tenantUsersTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
DeletedAt: DeletedAtColumn,
TenantID: TenantIDColumn,
UserID: UserIDColumn,
Status: StatusColumn,
Role: RoleColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,96 @@
//
// 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
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
ExpiredAt postgres.ColumnTimestamp
CreatedByUserID postgres.ColumnInteger
Name postgres.ColumnString
Slug postgres.ColumnString
Description postgres.ColumnString
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")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
ExpiredAtColumn = postgres.TimestampColumn("expired_at")
CreatedByUserIDColumn = postgres.IntegerColumn("created_by_user_id")
NameColumn = postgres.StringColumn("name")
SlugColumn = postgres.StringColumn("slug")
DescriptionColumn = postgres.StringColumn("description")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, ExpiredAtColumn, CreatedByUserIDColumn, NameColumn, SlugColumn, DescriptionColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, ExpiredAtColumn, CreatedByUserIDColumn, NameColumn, SlugColumn, DescriptionColumn}
)
return tenantsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
ExpiredAt: ExpiredAtColumn,
CreatedByUserID: CreatedByUserIDColumn,
Name: NameColumn,
Slug: SlugColumn,
Description: DescriptionColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,111 @@
//
// 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 UserOauths = newUserOauthsTable("public", "user_oauths", "")
type userOauthsTable struct {
postgres.Table
// Columns
ID postgres.ColumnInteger
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
DeletedAt postgres.ColumnTimestamp
Channel postgres.ColumnInteger
UserID postgres.ColumnInteger
UnionID postgres.ColumnString
OpenID postgres.ColumnString
AccessKey postgres.ColumnString
AccessToken postgres.ColumnString
RefreshToken postgres.ColumnString
ExpireAt postgres.ColumnTimestamp
Meta postgres.ColumnString
AllColumns postgres.ColumnList
MutableColumns postgres.ColumnList
}
type UserOauthsTable struct {
userOauthsTable
EXCLUDED userOauthsTable
}
// AS creates new UserOauthsTable with assigned alias
func (a UserOauthsTable) AS(alias string) *UserOauthsTable {
return newUserOauthsTable(a.SchemaName(), a.TableName(), alias)
}
// Schema creates new UserOauthsTable with assigned schema name
func (a UserOauthsTable) FromSchema(schemaName string) *UserOauthsTable {
return newUserOauthsTable(schemaName, a.TableName(), a.Alias())
}
// WithPrefix creates new UserOauthsTable with assigned table prefix
func (a UserOauthsTable) WithPrefix(prefix string) *UserOauthsTable {
return newUserOauthsTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
}
// WithSuffix creates new UserOauthsTable with assigned table suffix
func (a UserOauthsTable) WithSuffix(suffix string) *UserOauthsTable {
return newUserOauthsTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
}
func newUserOauthsTable(schemaName, tableName, alias string) *UserOauthsTable {
return &UserOauthsTable{
userOauthsTable: newUserOauthsTableImpl(schemaName, tableName, alias),
EXCLUDED: newUserOauthsTableImpl("", "excluded", ""),
}
}
func newUserOauthsTableImpl(schemaName, tableName, alias string) userOauthsTable {
var (
IDColumn = postgres.IntegerColumn("id")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
ChannelColumn = postgres.IntegerColumn("channel")
UserIDColumn = postgres.IntegerColumn("user_id")
UnionIDColumn = postgres.StringColumn("union_id")
OpenIDColumn = postgres.StringColumn("open_id")
AccessKeyColumn = postgres.StringColumn("access_key")
AccessTokenColumn = postgres.StringColumn("access_token")
RefreshTokenColumn = postgres.StringColumn("refresh_token")
ExpireAtColumn = postgres.TimestampColumn("expire_at")
MetaColumn = postgres.StringColumn("meta")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, ChannelColumn, UserIDColumn, UnionIDColumn, OpenIDColumn, AccessKeyColumn, AccessTokenColumn, RefreshTokenColumn, ExpireAtColumn, MetaColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, ChannelColumn, UserIDColumn, UnionIDColumn, OpenIDColumn, AccessKeyColumn, AccessTokenColumn, RefreshTokenColumn, ExpireAtColumn, MetaColumn}
)
return userOauthsTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
DeletedAt: DeletedAtColumn,
Channel: ChannelColumn,
UserID: UserIDColumn,
UnionID: UnionIDColumn,
OpenID: OpenIDColumn,
AccessKey: AccessKeyColumn,
AccessToken: AccessTokenColumn,
RefreshToken: RefreshTokenColumn,
ExpireAt: ExpireAtColumn,
Meta: MetaColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,111 @@
//
// 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
CreatedAt postgres.ColumnTimestamp
UpdatedAt postgres.ColumnTimestamp
DeletedAt postgres.ColumnTimestamp
Status postgres.ColumnInteger
Email postgres.ColumnString
Phone postgres.ColumnString
Username postgres.ColumnString
Nickname postgres.ColumnString
Password postgres.ColumnString
Age postgres.ColumnInteger
Sex postgres.ColumnInteger
Avatar postgres.ColumnString
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")
CreatedAtColumn = postgres.TimestampColumn("created_at")
UpdatedAtColumn = postgres.TimestampColumn("updated_at")
DeletedAtColumn = postgres.TimestampColumn("deleted_at")
StatusColumn = postgres.IntegerColumn("status")
EmailColumn = postgres.StringColumn("email")
PhoneColumn = postgres.StringColumn("phone")
UsernameColumn = postgres.StringColumn("username")
NicknameColumn = postgres.StringColumn("nickname")
PasswordColumn = postgres.StringColumn("password")
AgeColumn = postgres.IntegerColumn("age")
SexColumn = postgres.IntegerColumn("sex")
AvatarColumn = postgres.StringColumn("avatar")
allColumns = postgres.ColumnList{IDColumn, CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, StatusColumn, EmailColumn, PhoneColumn, UsernameColumn, NicknameColumn, PasswordColumn, AgeColumn, SexColumn, AvatarColumn}
mutableColumns = postgres.ColumnList{CreatedAtColumn, UpdatedAtColumn, DeletedAtColumn, StatusColumn, EmailColumn, PhoneColumn, UsernameColumn, NicknameColumn, PasswordColumn, AgeColumn, SexColumn, AvatarColumn}
)
return usersTable{
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
//Columns
ID: IDColumn,
CreatedAt: CreatedAtColumn,
UpdatedAt: UpdatedAtColumn,
DeletedAt: DeletedAtColumn,
Status: StatusColumn,
Email: EmailColumn,
Phone: PhoneColumn,
Username: UsernameColumn,
Nickname: NicknameColumn,
Password: PasswordColumn,
Age: AgeColumn,
Sex: SexColumn,
Avatar: AvatarColumn,
AllColumns: allColumns,
MutableColumns: mutableColumns,
}
}

View File

@@ -0,0 +1,11 @@
ignores:
- migrations
- river_client
- river_client_queue
- river_job
- river_leader
- river_queue
# types:
# users: # table name
# meta: UserMeta
# meta: Json[UserMeta]