feat: add backend_v1 migration
Some checks failed
build quyun / Build (push) Has been cancelled

This commit is contained in:
2025-12-19 14:46:58 +08:00
parent 218eb4689c
commit 24bd161df9
119 changed files with 12259 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE medias(
id SERIAL8 PRIMARY KEY,
created_at timestamp NOT NULL DEFAULT now(),
name varchar(255) NOT NULL DEFAULT '',
mime_type varchar(128) NOT NULL DEFAULT '',
size int8 NOT NULL DEFAULT 0,
path varchar(255) NOT NULL DEFAULT '',
metas jsonb NOT NULL DEFAULT '{}' ::jsonb,
hash varchar(64) NOT NULL DEFAULT ''
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE medias;
-- +goose StatementEnd

View File

@@ -0,0 +1,26 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE posts(
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,
title varchar(128) NOT NULL,
head_images jsonb DEFAULT '[]' ::jsonb NOT NULL,
description varchar(256) NOT NULL,
content text NOT NULL,
price int8 NOT NULL DEFAULT 0,
discount int2 NOT NULL DEFAULT 100,
views int8 NOT NULL DEFAULT 0,
likes int8 NOT NULL DEFAULT 0,
tags jsonb DEFAULT '{}' ::jsonb,
assets jsonb DEFAULT '{}' ::jsonb
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE posts;
-- +goose StatementEnd

View File

@@ -0,0 +1,22 @@
-- +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,
open_id varchar(128) NOT NULL UNIQUE,
username varchar(128) NOT NULL,
avatar text
);
SELECT
setval('users_id_seq', 1000);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE users;
-- +goose StatementEnd

View File

@@ -0,0 +1,18 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE user_posts(
id SERIAL8 PRIMARY KEY,
created_at timestamp NOT NULL DEFAULT now(),
updated_at timestamp NOT NULL DEFAULT now(),
--
user_id int8 NOT NULL,
post_id int8 NOT NULL,
price int8 NOT NULL
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE user_posts;
-- +goose StatementEnd

View File

@@ -0,0 +1,26 @@
-- +goose Up
-- +goose StatementBegin
CREATE TABLE orders(
id SERIAL8 PRIMARY KEY,
created_at timestamp NOT NULL DEFAULT now(),
updated_at timestamp NOT NULL DEFAULT now(),
order_no varchar(64) NOT NULL,
sub_order_no varchar(64) NOT NULL DEFAULT '',
transaction_id varchar(64) NOT NULL DEFAULT '',
refund_transaction_id varchar(64) NOT NULL DEFAULT '',
price int8 NOT NULL DEFAULT 0,
discount int2 NOT NULL DEFAULT 100,
currency varchar(10) NOT NULL DEFAULT 'CNY',
payment_method varchar(50) NOT NULL DEFAULT 'wechatpay',
post_id int8 NOT NULL,
user_id int8 NOT NULL,
status int2 NOT NULL,
meta jsonb NOT NULL DEFAULT '{}' ::jsonb
);
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
DROP TABLE orders;
-- +goose StatementEnd

View File

@@ -0,0 +1,18 @@
-- +goose Up
-- +goose StatementBegin
ALTER TABLE public.users
ADD metas jsonb DEFAULT '{}'::jsonb NOT NULL;
ALTER TABLE public.users
ADD auth_token jsonb DEFAULT '{}'::jsonb NOT NULL;
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
ALTER TABLE public.users
DROP COLUMN metas;
ALTER TABLE public.users
DROP COLUMN auth_token;
-- +goose StatementEnd

View File

@@ -0,0 +1,11 @@
-- +goose Up
-- +goose StatementBegin
ALTER TABLE public.users
ADD balance int8 DEFAULT 0 NOT NULL;
-- +goose StatementEnd
-- +goose Down
-- +goose StatementBegin
ALTER TABLE public.users
DROP COLUMN balance;
-- +goose StatementEnd