From 004a9e6bb51dab53fbc533b0e5c986548d0cdf9b Mon Sep 17 00:00:00 2001 From: vipg Date: Fri, 26 Dec 2025 16:11:21 +0800 Subject: [PATCH] add --- create/create.sh | 2 +- infra/postgres/sql/03_create_table.sql | 21 ++++++--------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/create/create.sh b/create/create.sh index 1c26fcb..1700524 100644 --- a/create/create.sh +++ b/create/create.sh @@ -26,7 +26,7 @@ docker run --rm \ -v "${PROJECT_ROOT}/infra/postgres/sql:/app/infra/postgres/sql" \ -w /app \ python:3.13.7-alpine3.22 \ - bash -c " + sh -c " echo '📋 容器内环境信息:' python --version echo '' diff --git a/infra/postgres/sql/03_create_table.sql b/infra/postgres/sql/03_create_table.sql index b8eeef5..f5435b3 100644 --- a/infra/postgres/sql/03_create_table.sql +++ b/infra/postgres/sql/03_create_table.sql @@ -1,12 +1,3 @@ --- ========================================================= --- table.sql (PostgreSQL 17.4+) --- ========================================================= -\pset pager off -\timing on -\c postgres; - -CREATE EXTENSION IF NOT EXISTS "moddatetime" SCHEMA public; - DO $$ BEGIN RAISE NOTICE '🚀============ 数据库表部署开始 ============🚀'; @@ -21,15 +12,15 @@ BEGIN AND table_name = 'cn_futures_trading_records' ) THEN CREATE TABLE cn_futures_trading_records ( - id UUID DEFAULT gen_random_uuid() PRIMARY KEY, -- id - payload JSONB NOT NULL, -- 数据 - deleted BOOLEAN NOT NULL DEFAULT FALSE, -- 删除状态 - created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, -- 记录创建时间 - updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -- 记录修改时间 + id UUID DEFAULT gen_random_uuid() PRIMARY KEY, -- id + payload JSONB NOT NULL, -- 数据 + deleted BOOLEAN NOT NULL DEFAULT FALSE, -- 删除状态 + created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, -- 记录创建时间 + updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP -- 记录修改时间 ); -- 3 触发器:自动刷新 updated_at - CREATE TRIGGER trg_cn_futures_trading_records_updated_at + CREATE TRIGGER trg_cn_futures_trading_records_at BEFORE UPDATE ON cn_futures_trading_records FOR EACH ROW EXECUTE FUNCTION moddatetime(updated_at);