feat: 新增支付配置管理相关数据库迁移(000078-000081)
- 000078: 创建 tb_wechat_config 表(支持微信直连和富友双渠道,含软删除) - 000079: tb_order 新增 payment_config_id 字段(nullable,记录下单时使用的配置) - 000080: tb_asset_recharge_record 新增 payment_config_id 字段 - 000081: tb_agent_recharge_record 新增 payment_config_id 字段 Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
1
migrations/000078_create_wechat_config_table.down.sql
Normal file
1
migrations/000078_create_wechat_config_table.down.sql
Normal file
@@ -0,0 +1 @@
|
||||
DROP TABLE IF EXISTS tb_wechat_config;
|
||||
53
migrations/000078_create_wechat_config_table.up.sql
Normal file
53
migrations/000078_create_wechat_config_table.up.sql
Normal file
@@ -0,0 +1,53 @@
|
||||
-- 创建微信参数配置表
|
||||
CREATE TABLE tb_wechat_config (
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
name VARCHAR(100) NOT NULL,
|
||||
description TEXT,
|
||||
provider_type VARCHAR(20) NOT NULL,
|
||||
is_active BOOLEAN NOT NULL DEFAULT FALSE,
|
||||
|
||||
-- OAuth 公众号
|
||||
oa_app_id VARCHAR(100) NOT NULL DEFAULT '',
|
||||
oa_app_secret VARCHAR(200) NOT NULL DEFAULT '',
|
||||
oa_token VARCHAR(200) DEFAULT '',
|
||||
oa_aes_key VARCHAR(200) DEFAULT '',
|
||||
oa_oauth_redirect_url VARCHAR(500) DEFAULT '',
|
||||
|
||||
-- OAuth 小程序
|
||||
miniapp_app_id VARCHAR(100) DEFAULT '',
|
||||
miniapp_app_secret VARCHAR(200) DEFAULT '',
|
||||
|
||||
-- 支付-微信直连
|
||||
wx_mch_id VARCHAR(100) DEFAULT '',
|
||||
wx_api_v3_key VARCHAR(200) DEFAULT '',
|
||||
wx_api_v2_key VARCHAR(200) DEFAULT '',
|
||||
wx_cert_content TEXT DEFAULT '',
|
||||
wx_key_content TEXT DEFAULT '',
|
||||
wx_serial_no VARCHAR(200) DEFAULT '',
|
||||
wx_notify_url VARCHAR(500) DEFAULT '',
|
||||
|
||||
-- 支付-富友
|
||||
fy_ins_cd VARCHAR(50) DEFAULT '',
|
||||
fy_mchnt_cd VARCHAR(50) DEFAULT '',
|
||||
fy_term_id VARCHAR(50) DEFAULT '',
|
||||
fy_private_key TEXT DEFAULT '',
|
||||
fy_public_key TEXT DEFAULT '',
|
||||
fy_api_url VARCHAR(500) DEFAULT '',
|
||||
fy_notify_url VARCHAR(500) DEFAULT '',
|
||||
|
||||
-- 审计字段
|
||||
creator BIGINT NOT NULL DEFAULT 0,
|
||||
updater BIGINT NOT NULL DEFAULT 0,
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
|
||||
deleted_at TIMESTAMPTZ
|
||||
);
|
||||
|
||||
CREATE INDEX idx_wechat_config_is_active ON tb_wechat_config(is_active) WHERE deleted_at IS NULL;
|
||||
CREATE INDEX idx_wechat_config_provider_type ON tb_wechat_config(provider_type) WHERE deleted_at IS NULL;
|
||||
CREATE INDEX idx_wechat_config_deleted_at ON tb_wechat_config(deleted_at);
|
||||
|
||||
COMMENT ON TABLE tb_wechat_config IS '微信参数配置表';
|
||||
COMMENT ON COLUMN tb_wechat_config.name IS '配置名称';
|
||||
COMMENT ON COLUMN tb_wechat_config.provider_type IS '支付渠道类型: wechat-微信直连, fuiou-富友';
|
||||
COMMENT ON COLUMN tb_wechat_config.is_active IS '是否激活(全局唯一)';
|
||||
@@ -0,0 +1,2 @@
|
||||
DROP INDEX IF EXISTS idx_order_payment_config_id;
|
||||
ALTER TABLE tb_order DROP COLUMN IF EXISTS payment_config_id;
|
||||
4
migrations/000079_add_payment_config_id_to_order.up.sql
Normal file
4
migrations/000079_add_payment_config_id_to_order.up.sql
Normal file
@@ -0,0 +1,4 @@
|
||||
-- tb_order 新增 payment_config_id 列
|
||||
ALTER TABLE tb_order ADD COLUMN payment_config_id BIGINT;
|
||||
COMMENT ON COLUMN tb_order.payment_config_id IS '支付配置ID(关联tb_wechat_config.id)';
|
||||
CREATE INDEX idx_order_payment_config_id ON tb_order(payment_config_id) WHERE payment_config_id IS NOT NULL;
|
||||
@@ -0,0 +1,2 @@
|
||||
DROP INDEX IF EXISTS idx_asset_recharge_payment_config_id;
|
||||
ALTER TABLE tb_asset_recharge_record DROP COLUMN IF EXISTS payment_config_id;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- tb_asset_recharge_record 新增 payment_config_id 列
|
||||
ALTER TABLE tb_asset_recharge_record ADD COLUMN payment_config_id BIGINT;
|
||||
COMMENT ON COLUMN tb_asset_recharge_record.payment_config_id IS '支付配置ID(关联tb_wechat_config.id)';
|
||||
CREATE INDEX idx_asset_recharge_payment_config_id ON tb_asset_recharge_record(payment_config_id) WHERE payment_config_id IS NOT NULL;
|
||||
@@ -0,0 +1,3 @@
|
||||
-- 回滚:删除代理充值记录的支付配置ID字段
|
||||
DROP INDEX IF EXISTS idx_agent_recharge_payment_config_id;
|
||||
ALTER TABLE tb_agent_recharge_record DROP COLUMN IF EXISTS payment_config_id;
|
||||
@@ -0,0 +1,4 @@
|
||||
-- 为代理充值记录添加支付配置ID字段
|
||||
ALTER TABLE tb_agent_recharge_record ADD COLUMN payment_config_id BIGINT;
|
||||
COMMENT ON COLUMN tb_agent_recharge_record.payment_config_id IS '支付配置ID(关联tb_wechat_config.id)';
|
||||
CREATE INDEX idx_agent_recharge_payment_config_id ON tb_agent_recharge_record(payment_config_id) WHERE payment_config_id IS NOT NULL;
|
||||
Reference in New Issue
Block a user