From 91b663328bb69ea7242be2f70ad30c6a459e446e Mon Sep 17 00:00:00 2001 From: vipg Date: Fri, 26 Dec 2025 16:17:27 +0800 Subject: [PATCH] add --- create/create.py | 2 +- infra/postgres/sql/03_create_table.sql | 32 +------------------------- 2 files changed, 2 insertions(+), 32 deletions(-) diff --git a/create/create.py b/create/create.py index 1128bd7..a45af0e 100644 --- a/create/create.py +++ b/create/create.py @@ -8,7 +8,7 @@ import os import re # 1. 定义表名称变量,方便调整 -table_name = "cn_pmi_records" # 可以根据需要修改表名 +table_name = "cn_pmi_234_aaarecords" # 可以根据需要修改表名 # 2. 定义SQL模板 sql_template = f"""DO $$ diff --git a/infra/postgres/sql/03_create_table.sql b/infra/postgres/sql/03_create_table.sql index bcf4ad6..e759c42 100644 --- a/infra/postgres/sql/03_create_table.sql +++ b/infra/postgres/sql/03_create_table.sql @@ -3,37 +3,7 @@ BEGIN RAISE NOTICE '🚀============ 数据库表部署开始 ============🚀'; END $$; -DO $$ -BEGIN - IF NOT EXISTS ( - SELECT 1 - FROM information_schema.tables - WHERE table_schema = 'public' - AND table_name = 'cn_pmi_records' - ) THEN - CREATE TABLE cn_pmi_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 -- 记录修改时间 - ); - - -- 3 触发器:自动刷新 updated_at - CREATE TRIGGER trg_cn_pmi_records_at - BEFORE UPDATE ON cn_pmi_records - FOR EACH ROW - EXECUTE FUNCTION moddatetime(updated_at); - - RAISE NOTICE 'cn_pmi_records 表已创建'; - ELSE - RAISE NOTICE 'cn_pmi_records 表已存在,跳过'; - END IF; -END $$; - - - DO $$ BEGIN RAISE NOTICE '============ 数据库表部署完成 ============'; -END $$; \ No newline at end of file +END $$;