重构数据引擎

This commit is contained in:
2026-05-29 18:39:32 +08:00
parent 3ced686cb5
commit 15db71b7ba
132 changed files with 2534 additions and 26198 deletions

View File

@@ -1,38 +0,0 @@
-- PostgreSQL Database Schema for Data Engine
-- Generated from Go entity classes
-- This file serves as the main schema file that imports all other schema files
-- Execute in the following order:
-- 1. 00_main_schema.sql (this file)
-- 2. 01_dict_tables.sql
-- 3. 02_account_report_tables.sql
-- 4. 03_campaign_report_tables.sql
-- 5. 04_creative_report_tables.sql
-- 6. 05_unit_report_tables.sql
-- 7. 06_storewide_report_tables.sql
-- 8. 07_material_population_tables.sql
-- 9. 08_sync_task_tables.sql
-- =============================================
-- Database Settings
-- =============================================
-- Set timezone (optional, adjust as needed)
SET timezone = 'Asia/Shanghai';
-- =============================================
-- Import all schema files
-- =============================================
\i 01_dict_tables.sql
\i 02_account_report_tables.sql
\i 03_campaign_report_tables.sql
\i 04_creative_report_tables.sql
\i 05_unit_report_tables.sql
\i 06_storewide_report_tables.sql
\i 07_material_population_tables.sql
\i 08_sync_task_tables.sql
-- =============================================
-- Grant permissions (optional, adjust as needed)
-- =============================================
-- GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO your_user;
-- GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO your_user;

View File

@@ -1,183 +0,0 @@
-- PostgreSQL 建表脚本 - dict 包
-- =============================================
-- 数据源平台配置表 (api_datasource_platform)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS api_datasource_platform_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS api_datasource_platform (
id BIGINT NOT NULL DEFAULT nextval('api_datasource_platform_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
platform_code VARCHAR(100) NOT NULL,
platform_name VARCHAR(200) NOT NULL,
description TEXT,
status VARCHAR(50) DEFAULT 'ACTIVE',
api_base_url VARCHAR(500),
auth_type VARCHAR(50) DEFAULT 'API_KEY',
token VARCHAR(500),
api_key VARCHAR(500),
client_id VARCHAR(200),
client_secret VARCHAR(500),
rate_limit_per_minute INT DEFAULT 60,
rate_limit_per_hour INT DEFAULT 3600,
concurrency_limit INT DEFAULT 10,
request_timeout_ms INT DEFAULT 30000,
max_retries INT DEFAULT 3,
retry_delay_ms INT DEFAULT 1000,
version INT DEFAULT 0,
PRIMARY KEY (id)
);
COMMENT ON TABLE api_datasource_platform IS '数据源平台配置表';
COMMENT ON COLUMN api_datasource_platform.id IS '主键ID';
COMMENT ON COLUMN api_datasource_platform.tenant_id IS '租户ID';
COMMENT ON COLUMN api_datasource_platform.creator IS '创建人';
COMMENT ON COLUMN api_datasource_platform.created_at IS '创建时间';
COMMENT ON COLUMN api_datasource_platform.updater IS '更新人';
COMMENT ON COLUMN api_datasource_platform.updated_at IS '更新时间';
COMMENT ON COLUMN api_datasource_platform.deleted_at IS '软删除时间';
COMMENT ON COLUMN api_datasource_platform.platform_code IS '平台编码,唯一标识';
COMMENT ON COLUMN api_datasource_platform.platform_name IS '平台名称';
COMMENT ON COLUMN api_datasource_platform.description IS '平台描述';
COMMENT ON COLUMN api_datasource_platform.status IS '状态: ACTIVE启用, INACTIVE停用';
COMMENT ON COLUMN api_datasource_platform.api_base_url IS 'API基础地址';
COMMENT ON COLUMN api_datasource_platform.auth_type IS '认证类型: TOKEN/API_KEY/OAUTH2/BASIC';
COMMENT ON COLUMN api_datasource_platform.token IS '认证token/密钥';
COMMENT ON COLUMN api_datasource_platform.api_key IS 'API Key';
COMMENT ON COLUMN api_datasource_platform.client_id IS 'OAuth2 Client ID';
COMMENT ON COLUMN api_datasource_platform.client_secret IS 'OAuth2 Client Secret';
COMMENT ON COLUMN api_datasource_platform.rate_limit_per_minute IS '每分钟请求限制';
COMMENT ON COLUMN api_datasource_platform.rate_limit_per_hour IS '每小时请求限制';
COMMENT ON COLUMN api_datasource_platform.concurrency_limit IS '并发连接限制';
COMMENT ON COLUMN api_datasource_platform.request_timeout_ms IS '请求超时时间(毫秒)';
COMMENT ON COLUMN api_datasource_platform.max_retries IS '最大重试次数';
COMMENT ON COLUMN api_datasource_platform.retry_delay_ms IS '重试延迟(毫秒)';
COMMENT ON COLUMN api_datasource_platform.version IS '版本号(乐观锁)';
CREATE UNIQUE INDEX idx_api_datasource_platform_code ON api_datasource_platform(tenant_id, platform_code);
-- =============================================
-- 字段映射配置表 (api_field_mapping_config)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS api_field_mapping_config_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS api_field_mapping_config (
id BIGINT NOT NULL DEFAULT nextval('api_field_mapping_config_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
config_name VARCHAR(200) NOT NULL,
vendor_name VARCHAR(100),
api_name VARCHAR(200),
api_version VARCHAR(50),
source_field VARCHAR(200),
source_field_type VARCHAR(100),
source_field_desc VARCHAR(500),
target_field VARCHAR(200),
target_field_type VARCHAR(100),
target_field_desc VARCHAR(500),
transform_type VARCHAR(100),
transform_params JSONB,
validation_rules JSONB,
default_value VARCHAR(500),
is_required BOOLEAN DEFAULT FALSE,
is_active BOOLEAN DEFAULT TRUE,
priority INT DEFAULT 0,
business_domain VARCHAR(100),
field_group VARCHAR(100),
config_version INT DEFAULT 1,
effective_date TIMESTAMP WITH TIME ZONE,
expiry_date TIMESTAMP WITH TIME ZONE,
PRIMARY KEY (id)
);
COMMENT ON TABLE api_field_mapping_config IS '字段映射配置表';
COMMENT ON COLUMN api_field_mapping_config.id IS '主键ID';
COMMENT ON COLUMN api_field_mapping_config.tenant_id IS '租户ID';
COMMENT ON COLUMN api_field_mapping_config.creator IS '创建人';
COMMENT ON COLUMN api_field_mapping_config.created_at IS '创建时间';
COMMENT ON COLUMN api_field_mapping_config.updater IS '更新人';
COMMENT ON COLUMN api_field_mapping_config.updated_at IS '更新时间';
COMMENT ON COLUMN api_field_mapping_config.deleted_at IS '软删除时间';
COMMENT ON COLUMN api_field_mapping_config.config_name IS '配置名称';
COMMENT ON COLUMN api_field_mapping_config.vendor_name IS '厂商名称';
COMMENT ON COLUMN api_field_mapping_config.api_name IS '接口名称';
COMMENT ON COLUMN api_field_mapping_config.api_version IS '接口版本';
COMMENT ON COLUMN api_field_mapping_config.source_field IS '源字段名';
COMMENT ON COLUMN api_field_mapping_config.source_field_type IS '源字段数据类型';
COMMENT ON COLUMN api_field_mapping_config.source_field_desc IS '源字段描述';
COMMENT ON COLUMN api_field_mapping_config.target_field IS '目标字段名';
COMMENT ON COLUMN api_field_mapping_config.target_field_type IS '目标数据类型';
COMMENT ON COLUMN api_field_mapping_config.target_field_desc IS '字段描述';
COMMENT ON COLUMN api_field_mapping_config.transform_type IS '转换类型';
COMMENT ON COLUMN api_field_mapping_config.transform_params IS '转换参数';
COMMENT ON COLUMN api_field_mapping_config.validation_rules IS '验证规则';
COMMENT ON COLUMN api_field_mapping_config.default_value IS '默认值';
COMMENT ON COLUMN api_field_mapping_config.is_required IS '是否必填';
COMMENT ON COLUMN api_field_mapping_config.is_active IS '是否启用';
COMMENT ON COLUMN api_field_mapping_config.priority IS '优先级';
COMMENT ON COLUMN api_field_mapping_config.business_domain IS '业务域';
COMMENT ON COLUMN api_field_mapping_config.field_group IS '字段分组';
COMMENT ON COLUMN api_field_mapping_config.config_version IS '配置版本号';
COMMENT ON COLUMN api_field_mapping_config.effective_date IS '生效时间';
COMMENT ON COLUMN api_field_mapping_config.expiry_date IS '失效时间';
CREATE INDEX idx_api_field_mapping_config_vendor ON api_field_mapping_config(tenant_id, vendor_name, api_name);
CREATE INDEX idx_api_field_mapping_config_active ON api_field_mapping_config(tenant_id, is_active);
-- =============================================
-- API接口管理表 (api_interface)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS api_interface_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS api_interface (
id BIGINT NOT NULL DEFAULT nextval('api_interface_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
platform_id BIGINT NOT NULL,
name VARCHAR(200) NOT NULL,
code VARCHAR(100) NOT NULL,
url VARCHAR(500) NOT NULL,
method VARCHAR(20) NOT NULL DEFAULT 'GET',
status VARCHAR(50) DEFAULT 'active',
auth_type VARCHAR(50) DEFAULT 'api_key',
request_config JSONB,
response_config JSONB,
limit_config JSONB,
PRIMARY KEY (id)
);
COMMENT ON TABLE api_interface IS 'API接口管理表';
COMMENT ON COLUMN api_interface.id IS '主键ID';
COMMENT ON COLUMN api_interface.tenant_id IS '租户ID';
COMMENT ON COLUMN api_interface.creator IS '创建人';
COMMENT ON COLUMN api_interface.created_at IS '创建时间';
COMMENT ON COLUMN api_interface.updater IS '更新人';
COMMENT ON COLUMN api_interface.updated_at IS '更新时间';
COMMENT ON COLUMN api_interface.deleted_at IS '软删除时间';
COMMENT ON COLUMN api_interface.platform_id IS '所属平台ID';
COMMENT ON COLUMN api_interface.name IS '接口名称';
COMMENT ON COLUMN api_interface.code IS '接口编码';
COMMENT ON COLUMN api_interface.url IS '接口地址';
COMMENT ON COLUMN api_interface.method IS '请求方法GET/POST/PUT/DELETE等';
COMMENT ON COLUMN api_interface.status IS '接口状态active启用/inactive停用';
COMMENT ON COLUMN api_interface.auth_type IS '认证类型oauth2/apikey/basic等';
COMMENT ON COLUMN api_interface.request_config IS '请求配置';
COMMENT ON COLUMN api_interface.response_config IS '响应配置';
COMMENT ON COLUMN api_interface.limit_config IS '接口独立限流配置(可选,覆盖平台配置)';
CREATE UNIQUE INDEX idx_api_interface_code ON api_interface(tenant_id, code);
CREATE INDEX idx_api_interface_platform_id ON api_interface(tenant_id, platform_id);
CREATE INDEX idx_api_interface_status ON api_interface(tenant_id, status);

View File

@@ -1,115 +0,0 @@
-- PostgreSQL 建表脚本 - 账户报告表
-- =============================================
-- 账户报告明细表 (cid_account_report_detail)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS cid_account_report_detail_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS cid_account_report_detail (
id BIGINT NOT NULL DEFAULT nextval('cid_account_report_detail_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
report_date_str VARCHAR(50),
account_id VARCHAR(100),
account_name VARCHAR(200),
cost_total DECIMAL(20,4),
impression BIGINT,
click BIGINT,
ctr DECIMAL(10,6),
cpc DECIMAL(20,4),
cpm DECIMAL(20,4),
conversion BIGINT,
conversion_rate DECIMAL(10,6),
cpa DECIMAL(20,4),
datasource VARCHAR(64) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
COMMENT ON TABLE cid_account_report_detail IS '账户报告明细表';
COMMENT ON COLUMN cid_account_report_detail.id IS '主键ID';
COMMENT ON COLUMN cid_account_report_detail.tenant_id IS '租户ID';
COMMENT ON COLUMN cid_account_report_detail.creator IS '创建人';
COMMENT ON COLUMN cid_account_report_detail.created_at IS '创建时间';
COMMENT ON COLUMN cid_account_report_detail.updater IS '更新人';
COMMENT ON COLUMN cid_account_report_detail.updated_at IS '更新时间';
COMMENT ON COLUMN cid_account_report_detail.deleted_at IS '软删除时间';
COMMENT ON COLUMN cid_account_report_detail.cid IS '广告账户ID';
COMMENT ON COLUMN cid_account_report_detail.report_date_str IS '报告日期';
COMMENT ON COLUMN cid_account_report_detail.account_id IS '账户ID';
COMMENT ON COLUMN cid_account_report_detail.account_name IS '账户名称';
COMMENT ON COLUMN cid_account_report_detail.cost_total IS '总花费';
COMMENT ON COLUMN cid_account_report_detail.impression IS '曝光数';
COMMENT ON COLUMN cid_account_report_detail.click IS '点击数';
COMMENT ON COLUMN cid_account_report_detail.ctr IS '点击率';
COMMENT ON COLUMN cid_account_report_detail.cpc IS '点击单价';
COMMENT ON COLUMN cid_account_report_detail.cpm IS '千次曝光成本';
COMMENT ON COLUMN cid_account_report_detail.conversion IS '转化数';
COMMENT ON COLUMN cid_account_report_detail.conversion_rate IS '转化率';
COMMENT ON COLUMN cid_account_report_detail.cpa IS '转化成本';
COMMENT ON COLUMN cid_account_report_detail.datasource IS '数据源';
CREATE INDEX idx_cid_account_report_detail_cid ON cid_account_report_detail(tenant_id, cid);
CREATE INDEX idx_cid_account_report_detail_date ON cid_account_report_detail(tenant_id, report_date_str);
CREATE INDEX idx_cid_account_report_detail_datasource ON cid_account_report_detail(tenant_id, datasource);
-- =============================================
-- 账户报告汇总表 (cid_account_report_sum)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS cid_account_report_sum_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS cid_account_report_sum (
id BIGINT NOT NULL DEFAULT nextval('cid_account_report_sum_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
report_date_str VARCHAR(50),
account_id VARCHAR(100),
account_name VARCHAR(200),
cost_total DECIMAL(20,4),
impression BIGINT,
click BIGINT,
ctr DECIMAL(10,6),
cpc DECIMAL(20,4),
cpm DECIMAL(20,4),
conversion BIGINT,
conversion_rate DECIMAL(10,6),
cpa DECIMAL(20,4),
datasource VARCHAR(64) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
COMMENT ON TABLE cid_account_report_sum IS '账户报告汇总表';
COMMENT ON COLUMN cid_account_report_sum.id IS '主键ID';
COMMENT ON COLUMN cid_account_report_sum.tenant_id IS '租户ID';
COMMENT ON COLUMN cid_account_report_sum.creator IS '创建人';
COMMENT ON COLUMN cid_account_report_sum.created_at IS '创建时间';
COMMENT ON COLUMN cid_account_report_sum.updater IS '更新人';
COMMENT ON COLUMN cid_account_report_sum.updated_at IS '更新时间';
COMMENT ON COLUMN cid_account_report_sum.deleted_at IS '软删除时间';
COMMENT ON COLUMN cid_account_report_sum.cid IS '广告账户ID';
COMMENT ON COLUMN cid_account_report_sum.report_date_str IS '报告日期';
COMMENT ON COLUMN cid_account_report_sum.account_id IS '账户ID';
COMMENT ON COLUMN cid_account_report_sum.account_name IS '账户名称';
COMMENT ON COLUMN cid_account_report_sum.cost_total IS '总花费';
COMMENT ON COLUMN cid_account_report_sum.impression IS '曝光数';
COMMENT ON COLUMN cid_account_report_sum.click IS '点击数';
COMMENT ON COLUMN cid_account_report_sum.ctr IS '点击率';
COMMENT ON COLUMN cid_account_report_sum.cpc IS '点击单价';
COMMENT ON COLUMN cid_account_report_sum.cpm IS '千次曝光成本';
COMMENT ON COLUMN cid_account_report_sum.conversion IS '转化数';
COMMENT ON COLUMN cid_account_report_sum.conversion_rate IS '转化率';
COMMENT ON COLUMN cid_account_report_sum.cpa IS '转化成本';
COMMENT ON COLUMN cid_account_report_sum.datasource IS '数据源';
CREATE INDEX idx_cid_account_report_sum_cid ON cid_account_report_sum(tenant_id, cid);
CREATE INDEX idx_cid_account_report_sum_date ON cid_account_report_sum(tenant_id, report_date_str);
CREATE INDEX idx_cid_account_report_sum_datasource ON cid_account_report_sum(tenant_id, datasource);

View File

@@ -1,419 +0,0 @@
-- PostgreSQL 建表脚本 - 广告系列报告表
-- =============================================
-- 广告系列报告明细表 (campaign_report_detail)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS campaign_report_detail_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS campaign_report_detail (
id BIGINT NOT NULL DEFAULT nextval('campaign_report_detail_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
datasource VARCHAR(64) NOT NULL DEFAULT '',
t0_order_payment_amt DECIMAL(20,4),
creative_material_type VARCHAR(100),
live_name VARCHAR(200),
author_id VARCHAR(100),
pic_url VARCHAR(500),
pic_name VARCHAR(200),
pic_id VARCHAR(100),
cover_url VARCHAR(500),
cover_id BIGINT,
item_order_conversion_ratio DECIMAL(10,6),
item_card_click_ratio DECIMAL(10,6),
item_card_clk_cnt BIGINT,
live_play_cnt_cost DECIMAL(20,4),
ad_merchant_follow_cost DECIMAL(20,4),
ad_merchant_follow BIGINT,
net_t0_order_cnt BIGINT,
net_t0_roi DECIMAL(10,6),
net_t0_gmv DECIMAL(20,4),
photo_name VARCHAR(200),
photo_id_str VARCHAR(100),
photo_id VARCHAR(100),
mod_price_segment VARCHAR(100),
age_segment VARCHAR(100),
province VARCHAR(100),
gender VARCHAR(20),
ad_photo_played_five_ratio DECIMAL(10,6),
ad_photo_played_three_ratio DECIMAL(10,6),
order_submit_roi DECIMAL(10,6),
order_submit_amt BIGINT,
event_order_submit_cost DECIMAL(20,4),
event_order_submit BIGINT,
event_order_paid_roi DECIMAL(10,6),
event_app_invoked BIGINT,
event_add_shopping_cart BIGINT,
conversion_num_cost DECIMAL(20,4),
ad_effective_play_num BIGINT,
ad_item_click BIGINT,
merchant_product_id VARCHAR(100),
cost_total DECIMAL(20,4),
ad_show BIGINT,
ad_show1k_cost DECIMAL(20,4),
impression BIGINT,
photo_click BIGINT,
photo_click_ratio DECIMAL(10,6),
click BIGINT,
actionbar_click BIGINT,
actionbar_click_cost DECIMAL(20,4),
esp_click_ratio DECIMAL(10,6),
action_ratio DECIMAL(10,6),
ad_item_click_count BIGINT,
esp_live_played_seconds BIGINT,
played_three_seconds BIGINT,
play3s_ratio DECIMAL(10,6),
played_five_seconds BIGINT,
play5s_ratio DECIMAL(10,6),
played_end BIGINT,
play_end_ratio DECIMAL(10,6),
share BIGINT,
comment BIGINT,
likes BIGINT,
report BIGINT,
block BIGINT,
item_negative BIGINT,
live_share BIGINT,
live_comment BIGINT,
live_reward BIGINT,
effective_play_count BIGINT,
effective_play_ratio DECIMAL(10,6),
conversion_num BIGINT,
conversion_cost_esp DECIMAL(20,4),
roi DECIMAL(10,6),
gmv DECIMAL(20,4),
t0_gmv DECIMAL(20,4),
t1_gmv DECIMAL(20,4),
t7_gmv DECIMAL(20,4),
t15_gmv DECIMAL(20,4),
t30_gmv DECIMAL(20,4),
t0_roi DECIMAL(10,6),
t1_roi DECIMAL(10,6),
t7_roi DECIMAL(10,6),
t15_roi DECIMAL(10,6),
t30_roi DECIMAL(10,6),
paied_order BIGINT,
order_ratio DECIMAL(10,6),
t0_order_cnt BIGINT,
t0_order_cnt_cost DECIMAL(20,4),
t0_order_cnt_ratio DECIMAL(10,6),
t1_order_cnt BIGINT,
t7_order_cnt BIGINT,
t15_order_cnt BIGINT,
t30_order_cnt BIGINT,
merchant_reco_fans BIGINT,
t1_retention DECIMAL(10,4),
t7_retention DECIMAL(10,4),
t15_retention DECIMAL(10,4),
t30_retention DECIMAL(10,4),
t1_retention_ratio DECIMAL(10,6),
t7_retention_ratio DECIMAL(10,6),
t15_retention_ratio DECIMAL(10,6),
t30_retention_ratio DECIMAL(10,6),
reservation_success BIGINT,
reservation_cost DECIMAL(20,4),
standard_live_played_started BIGINT,
ad_live_play_cnt BIGINT,
ad_live_play_cnt_cost DECIMAL(20,4),
live_audience_cost DECIMAL(20,4),
live_event_goods_view BIGINT,
goods_click_ratio DECIMAL(10,6),
direct_attr_plat_new_buyer_cnt BIGINT,
t30_attr_plat_total_buyer_cnt BIGINT,
direct_attr_seller_new_buyer_cnt BIGINT,
t30_attr_seller_total_buyer_cnt BIGINT,
t3_gmv DECIMAL(20,4),
t3_order_cnt BIGINT,
t3_roi DECIMAL(10,6),
t7_indirect_order_amt DECIMAL(20,4),
t7_indirect_order_cnt BIGINT,
fans_t0_gmv_per_fans DECIMAL(20,4),
fans_t3_gmv_per_fans DECIMAL(20,4),
fans_t7_gmv_per_fans DECIMAL(20,4),
fans_t15_gmv_per_fans DECIMAL(20,4),
fans_t30_gmv_per_fans DECIMAL(20,4),
reco_fans_cost DECIMAL(20,4),
qcpx_whitebox_direct_order_payment_amt DECIMAL(20,4),
qcpx_whitebox_direct_order_cnt BIGINT,
fans_t0_gmv DECIMAL(20,4),
fans_t1_gmv DECIMAL(20,4),
fans_t7_gmv DECIMAL(20,4),
fans_t15_gmv DECIMAL(20,4),
fans_t30_gmv DECIMAL(20,4),
fans_t0_roi DECIMAL(10,6),
fans_t1_roi DECIMAL(10,6),
fans_t7_roi DECIMAL(10,6),
fans_t15_roi DECIMAL(10,6),
fans_t30_roi DECIMAL(10,6),
t0_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t1_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t3_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t7_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t15_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t30_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t0_shop_new_buyer_order_cnt BIGINT,
t1_shop_new_buyer_order_cnt BIGINT,
t3_shop_new_buyer_order_cnt BIGINT,
t7_shop_new_buyer_order_cnt BIGINT,
t15_shop_new_buyer_order_cnt BIGINT,
t30_shop_new_buyer_order_cnt BIGINT,
t1_new_buyer_repurchase_ratio DECIMAL(10,6),
t3_new_buyer_repurchase_ratio DECIMAL(10,6),
t7_new_buyer_repurchase_ratio DECIMAL(10,6),
t15_new_buyer_repurchase_ratio DECIMAL(10,6),
t30_new_buyer_repurchase_ratio DECIMAL(10,6),
t0_shop_new_buyer_roi DECIMAL(10,6),
t1_shop_new_buyer_roi DECIMAL(10,6),
t3_shop_new_buyer_roi DECIMAL(10,6),
t7_shop_new_buyer_roi DECIMAL(10,6),
t15_shop_new_buyer_roi DECIMAL(10,6),
t30_shop_new_buyer_roi DECIMAL(10,6),
create_card_order_cnt BIGINT,
forward_ts_create_card_order_cnt BIGINT,
create_card_order_cost DECIMAL(20,4),
forward_ts_create_card_order_cost DECIMAL(20,4),
activate_card_order_cnt BIGINT,
forward_ts_activate_card_order_cnt BIGINT,
activate_card_order_cost DECIMAL(20,4),
forward_ts_activate_card_order_cost DECIMAL(20,4),
create_card_order_ratio DECIMAL(10,6),
forward_ts_create_card_order_ratio DECIMAL(10,6),
activate_card_order_cnt_ratio DECIMAL(10,6),
forward_ts_activate_card_order_ratio DECIMAL(10,6),
live_play_cnt BIGINT,
item_entrance_clk_cnt BIGINT,
show_cnt BIGINT,
report_date_str VARCHAR(50),
campaign_id BIGINT,
campaign_name VARCHAR(200),
unit_id BIGINT,
unit_name VARCHAR(200),
creative_id BIGINT,
creative_name VARCHAR(200),
cid_actual_roi_after_subsidy DECIMAL(10,6),
cid_coupon_amount BIGINT,
cid_coupon_callback_paid_refund_amount BIGINT,
cid_voucher_cost DECIMAL(20,4),
PRIMARY KEY (id)
);
COMMENT ON TABLE campaign_report_detail IS '广告系列报告明细表';
CREATE INDEX idx_campaign_report_detail_cid ON campaign_report_detail(tenant_id, cid);
CREATE INDEX idx_campaign_report_detail_campaign_id ON campaign_report_detail(tenant_id, campaign_id);
CREATE INDEX idx_campaign_report_detail_date ON campaign_report_detail(tenant_id, report_date_str);
CREATE INDEX idx_campaign_report_detail_datasource ON campaign_report_detail(tenant_id, datasource);
-- =============================================
-- 广告系列报告汇总表 (campaign_report_sum)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS campaign_report_sum_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS campaign_report_sum (
id BIGINT NOT NULL DEFAULT nextval('campaign_report_sum_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
datasource VARCHAR(64) NOT NULL DEFAULT '',
t0_order_payment_amt DECIMAL(20,4),
creative_material_type VARCHAR(100),
live_name VARCHAR(200),
author_id VARCHAR(100),
pic_url VARCHAR(500),
pic_name VARCHAR(200),
pic_id VARCHAR(100),
cover_url VARCHAR(500),
cover_id BIGINT,
item_order_conversion_ratio DECIMAL(10,6),
item_card_click_ratio DECIMAL(10,6),
item_card_clk_cnt BIGINT,
live_play_cnt_cost DECIMAL(20,4),
ad_merchant_follow_cost DECIMAL(20,4),
ad_merchant_follow BIGINT,
net_t0_order_cnt BIGINT,
net_t0_roi DECIMAL(10,6),
net_t0_gmv DECIMAL(20,4),
photo_name VARCHAR(200),
photo_id_str VARCHAR(100),
photo_id VARCHAR(100),
mod_price_segment VARCHAR(100),
age_segment VARCHAR(100),
province VARCHAR(100),
gender VARCHAR(20),
ad_photo_played_five_ratio DECIMAL(10,6),
ad_photo_played_three_ratio DECIMAL(10,6),
order_submit_roi DECIMAL(10,6),
order_submit_amt BIGINT,
event_order_submit_cost DECIMAL(20,4),
event_order_submit BIGINT,
event_order_paid_roi DECIMAL(10,6),
event_app_invoked BIGINT,
event_add_shopping_cart BIGINT,
conversion_num_cost DECIMAL(20,4),
ad_effective_play_num BIGINT,
ad_item_click BIGINT,
merchant_product_id VARCHAR(100),
cost_total DECIMAL(20,4),
ad_show BIGINT,
ad_show1k_cost DECIMAL(20,4),
impression BIGINT,
photo_click BIGINT,
photo_click_ratio DECIMAL(10,6),
click BIGINT,
actionbar_click BIGINT,
actionbar_click_cost DECIMAL(20,4),
esp_click_ratio DECIMAL(10,6),
action_ratio DECIMAL(10,6),
ad_item_click_count BIGINT,
esp_live_played_seconds BIGINT,
played_three_seconds BIGINT,
play3s_ratio DECIMAL(10,6),
played_five_seconds BIGINT,
play5s_ratio DECIMAL(10,6),
played_end BIGINT,
play_end_ratio DECIMAL(10,6),
share BIGINT,
comment BIGINT,
likes BIGINT,
report BIGINT,
block BIGINT,
item_negative BIGINT,
live_share BIGINT,
live_comment BIGINT,
live_reward BIGINT,
effective_play_count BIGINT,
effective_play_ratio DECIMAL(10,6),
conversion_num BIGINT,
conversion_cost_esp DECIMAL(20,4),
roi DECIMAL(10,6),
gmv DECIMAL(20,4),
t0_gmv DECIMAL(20,4),
t1_gmv DECIMAL(20,4),
t7_gmv DECIMAL(20,4),
t15_gmv DECIMAL(20,4),
t30_gmv DECIMAL(20,4),
t0_roi DECIMAL(10,6),
t1_roi DECIMAL(10,6),
t7_roi DECIMAL(10,6),
t15_roi DECIMAL(10,6),
t30_roi DECIMAL(10,6),
paied_order BIGINT,
order_ratio DECIMAL(10,6),
t0_order_cnt BIGINT,
t0_order_cnt_cost DECIMAL(20,4),
t0_order_cnt_ratio DECIMAL(10,6),
t1_order_cnt BIGINT,
t7_order_cnt BIGINT,
t15_order_cnt BIGINT,
t30_order_cnt BIGINT,
merchant_reco_fans BIGINT,
t1_retention DECIMAL(10,4),
t7_retention DECIMAL(10,4),
t15_retention DECIMAL(10,4),
t30_retention DECIMAL(10,4),
t1_retention_ratio DECIMAL(10,6),
t7_retention_ratio DECIMAL(10,6),
t15_retention_ratio DECIMAL(10,6),
t30_retention_ratio DECIMAL(10,6),
reservation_success BIGINT,
reservation_cost DECIMAL(20,4),
standard_live_played_started BIGINT,
ad_live_play_cnt BIGINT,
ad_live_play_cnt_cost DECIMAL(20,4),
live_audience_cost DECIMAL(20,4),
live_event_goods_view BIGINT,
goods_click_ratio DECIMAL(10,6),
direct_attr_plat_new_buyer_cnt BIGINT,
t30_attr_plat_total_buyer_cnt BIGINT,
direct_attr_seller_new_buyer_cnt BIGINT,
t30_attr_seller_total_buyer_cnt BIGINT,
t3_gmv DECIMAL(20,4),
t3_order_cnt BIGINT,
t3_roi DECIMAL(10,6),
t7_indirect_order_amt DECIMAL(20,4),
t7_indirect_order_cnt BIGINT,
fans_t0_gmv_per_fans DECIMAL(20,4),
fans_t3_gmv_per_fans DECIMAL(20,4),
fans_t7_gmv_per_fans DECIMAL(20,4),
fans_t15_gmv_per_fans DECIMAL(20,4),
fans_t30_gmv_per_fans DECIMAL(20,4),
reco_fans_cost DECIMAL(20,4),
qcpx_whitebox_direct_order_payment_amt DECIMAL(20,4),
qcpx_whitebox_direct_order_cnt BIGINT,
fans_t0_gmv DECIMAL(20,4),
fans_t1_gmv DECIMAL(20,4),
fans_t7_gmv DECIMAL(20,4),
fans_t15_gmv DECIMAL(20,4),
fans_t30_gmv DECIMAL(20,4),
fans_t0_roi DECIMAL(10,6),
fans_t1_roi DECIMAL(10,6),
fans_t7_roi DECIMAL(10,6),
fans_t15_roi DECIMAL(10,6),
fans_t30_roi DECIMAL(10,6),
t0_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t1_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t3_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t7_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t15_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t30_shop_new_buyer_order_payment_amt DECIMAL(20,4),
t0_shop_new_buyer_order_cnt BIGINT,
t1_shop_new_buyer_order_cnt BIGINT,
t3_shop_new_buyer_order_cnt BIGINT,
t7_shop_new_buyer_order_cnt BIGINT,
t15_shop_new_buyer_order_cnt BIGINT,
t30_shop_new_buyer_order_cnt BIGINT,
t1_new_buyer_repurchase_ratio DECIMAL(10,6),
t3_new_buyer_repurchase_ratio DECIMAL(10,6),
t7_new_buyer_repurchase_ratio DECIMAL(10,6),
t15_new_buyer_repurchase_ratio DECIMAL(10,6),
t30_new_buyer_repurchase_ratio DECIMAL(10,6),
t0_shop_new_buyer_roi DECIMAL(10,6),
t1_shop_new_buyer_roi DECIMAL(10,6),
t3_shop_new_buyer_roi DECIMAL(10,6),
t7_shop_new_buyer_roi DECIMAL(10,6),
t15_shop_new_buyer_roi DECIMAL(10,6),
t30_shop_new_buyer_roi DECIMAL(10,6),
create_card_order_cnt BIGINT,
forward_ts_create_card_order_cnt BIGINT,
create_card_order_cost DECIMAL(20,4),
forward_ts_create_card_order_cost DECIMAL(20,4),
activate_card_order_cnt BIGINT,
forward_ts_activate_card_order_cnt BIGINT,
activate_card_order_cost DECIMAL(20,4),
forward_ts_activate_card_order_cost DECIMAL(20,4),
create_card_order_ratio DECIMAL(10,6),
forward_ts_create_card_order_ratio DECIMAL(10,6),
activate_card_order_cnt_ratio DECIMAL(10,6),
forward_ts_activate_card_order_ratio DECIMAL(10,6),
live_play_cnt BIGINT,
item_entrance_clk_cnt BIGINT,
show_cnt BIGINT,
report_date_str VARCHAR(50),
campaign_id BIGINT,
campaign_name VARCHAR(200),
unit_id BIGINT,
unit_name VARCHAR(200),
creative_id BIGINT,
creative_name VARCHAR(200),
cid_actual_roi_after_subsidy DECIMAL(10,6),
cid_coupon_amount BIGINT,
cid_coupon_callback_paid_refund_amount BIGINT,
cid_voucher_cost DECIMAL(20,4),
PRIMARY KEY (id)
);
COMMENT ON TABLE campaign_report_sum IS '广告系列报告汇总表';
CREATE INDEX idx_campaign_report_sum_cid ON campaign_report_sum(tenant_id, cid);
CREATE INDEX idx_campaign_report_sum_campaign_id ON campaign_report_sum(tenant_id, campaign_id);
CREATE INDEX idx_campaign_report_sum_date ON campaign_report_sum(tenant_id, report_date_str);
CREATE INDEX idx_campaign_report_sum_datasource ON campaign_report_sum(tenant_id, datasource);

View File

@@ -1,206 +0,0 @@
-- Creative Report Tables (创意报告表)
-- =============================================
-- 创意报告明细表 (creative_report_detail)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS creative_report_detail_id_seq;
CREATE TABLE IF NOT EXISTS creative_report_detail (
id BIGINT NOT NULL DEFAULT nextval('creative_report_detail_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
campaign_id VARCHAR(64) NOT NULL DEFAULT '',
adgroup_id VARCHAR(64) NOT NULL DEFAULT '',
ad_id VARCHAR(64) NOT NULL DEFAULT '',
ad_name VARCHAR(255) NOT NULL DEFAULT '',
render_mode VARCHAR(32) NOT NULL DEFAULT '',
inventory_type VARCHAR(32) NOT NULL DEFAULT '',
promotion_target_id VARCHAR(64) NOT NULL DEFAULT '',
material_hash VARCHAR(128) NOT NULL DEFAULT '',
impression DECIMAL(20,6) NOT NULL DEFAULT 0,
click DECIMAL(20,6) NOT NULL DEFAULT 0,
cost DECIMAL(20,6) NOT NULL DEFAULT 0,
ctr DECIMAL(20,8) NOT NULL DEFAULT 0,
cpc DECIMAL(20,8) NOT NULL DEFAULT 0,
cpm DECIMAL(20,8) NOT NULL DEFAULT 0,
conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
cpp DECIMAL(20,8) NOT NULL DEFAULT 0,
primary_url VARCHAR(1024) NOT NULL DEFAULT '',
video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0,
avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0,
video_interaction_count DECIMAL(20,6) NOT NULL DEFAULT 0,
video_three_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
video_five_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_engage_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_share_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_comment_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_like_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_repost_count DECIMAL(20,6) NOT NULL DEFAULT 0,
game_download_count DECIMAL(20,6) NOT NULL DEFAULT 0,
app_download_count DECIMAL(20,6) NOT NULL DEFAULT 0,
app_install_count DECIMAL(20,6) NOT NULL DEFAULT 0,
onsite_leads_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0,
day VARCHAR(10) NOT NULL DEFAULT '',
datasource VARCHAR(64) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
COMMENT ON TABLE creative_report_detail IS '创意报告明细表';
COMMENT ON COLUMN creative_report_detail.id IS '主键ID';
COMMENT ON COLUMN creative_report_detail.tenant_id IS '租户ID';
COMMENT ON COLUMN creative_report_detail.creator IS '创建人';
COMMENT ON COLUMN creative_report_detail.created_at IS '创建时间';
COMMENT ON COLUMN creative_report_detail.updater IS '更新人';
COMMENT ON COLUMN creative_report_detail.updated_at IS '更新时间';
COMMENT ON COLUMN creative_report_detail.deleted_at IS '软删除时间';
COMMENT ON COLUMN creative_report_detail.cid IS '广告账户ID';
COMMENT ON COLUMN creative_report_detail.campaign_id IS '广告系列ID';
COMMENT ON COLUMN creative_report_detail.adgroup_id IS '广告组ID';
COMMENT ON COLUMN creative_report_detail.ad_id IS '创意ID';
COMMENT ON COLUMN creative_report_detail.ad_name IS '创意名称';
COMMENT ON COLUMN creative_report_detail.render_mode IS '创意类型';
COMMENT ON COLUMN creative_report_detail.inventory_type IS '投放位置';
COMMENT ON COLUMN creative_report_detail.promotion_target_id IS '推广目标ID';
COMMENT ON COLUMN creative_report_detail.material_hash IS '素材哈希';
COMMENT ON COLUMN creative_report_detail.impression IS '展示数';
COMMENT ON COLUMN creative_report_detail.click IS '点击数';
COMMENT ON COLUMN creative_report_detail.cost IS '花费(元)';
COMMENT ON COLUMN creative_report_detail.ctr IS '点击率';
COMMENT ON COLUMN creative_report_detail.cpc IS '平均点击价格';
COMMENT ON COLUMN creative_report_detail.cpm IS '千次展现成本';
COMMENT ON COLUMN creative_report_detail.conversion IS '转化数';
COMMENT ON COLUMN creative_report_detail.conversion_rate IS '转化率';
COMMENT ON COLUMN creative_report_detail.cpp IS '单次转化成本';
COMMENT ON COLUMN creative_report_detail.primary_url IS '落地页URL';
COMMENT ON COLUMN creative_report_detail.video_play_count IS '视频播放次数';
COMMENT ON COLUMN creative_report_detail.video_play_uv IS '视频播放人数';
COMMENT ON COLUMN creative_report_detail.avg_video_play_duration IS '平均播放时长(秒)';
COMMENT ON COLUMN creative_report_detail.video_interaction_count IS '视频互动数';
COMMENT ON COLUMN creative_report_detail.video_three_second_play_count IS '视频3秒播放次数';
COMMENT ON COLUMN creative_report_detail.video_five_second_play_count IS '视频5秒播放次数';
COMMENT ON COLUMN creative_report_detail.tweet_engage_count IS '推文参与数';
COMMENT ON COLUMN creative_report_detail.tweet_share_count IS '推文分享数';
COMMENT ON COLUMN creative_report_detail.tweet_comment_count IS '推文评论数';
COMMENT ON COLUMN creative_report_detail.tweet_like_count IS '推文点赞数';
COMMENT ON COLUMN creative_report_detail.tweet_repost_count IS '推文转发数';
COMMENT ON COLUMN creative_report_detail.game_download_count IS '游戏下载数';
COMMENT ON COLUMN creative_report_detail.app_download_count IS '应用下载数';
COMMENT ON COLUMN creative_report_detail.app_install_count IS '应用安装数';
COMMENT ON COLUMN creative_report_detail.onsite_leads_count IS '预注册数';
COMMENT ON COLUMN creative_report_detail.deep_convert_count IS '深度转化数';
COMMENT ON COLUMN creative_report_detail.deep_convert_rate IS '深度转化率';
COMMENT ON COLUMN creative_report_detail.deep_convert_cost IS '深度转化成本';
COMMENT ON COLUMN creative_report_detail.day IS '数据日期';
COMMENT ON COLUMN creative_report_detail.datasource IS '数据源';
CREATE INDEX idx_creative_report_detail_cid ON creative_report_detail(tenant_id, cid);
CREATE INDEX idx_creative_report_detail_campaign_id ON creative_report_detail(tenant_id, campaign_id);
CREATE INDEX idx_creative_report_detail_ad_id ON creative_report_detail(tenant_id, ad_id);
CREATE INDEX idx_creative_report_detail_day ON creative_report_detail(tenant_id, day);
CREATE INDEX idx_creative_report_detail_datasource ON creative_report_detail(tenant_id, datasource);
CREATE INDEX idx_creative_report_detail_material_hash ON creative_report_detail(tenant_id, material_hash);
-- =============================================
-- 创意报告汇总表 (creative_report_sum)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS creative_report_sum_id_seq;
CREATE TABLE IF NOT EXISTS creative_report_sum (
id BIGINT NOT NULL DEFAULT nextval('creative_report_sum_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
campaign_id VARCHAR(64) NOT NULL DEFAULT '',
adgroup_id VARCHAR(64) NOT NULL DEFAULT '',
ad_id VARCHAR(64) NOT NULL DEFAULT '',
ad_name VARCHAR(255) NOT NULL DEFAULT '',
render_mode VARCHAR(32) NOT NULL DEFAULT '',
inventory_type VARCHAR(32) NOT NULL DEFAULT '',
promotion_target_id VARCHAR(64) NOT NULL DEFAULT '',
impression DECIMAL(20,6) NOT NULL DEFAULT 0,
click DECIMAL(20,6) NOT NULL DEFAULT 0,
cost DECIMAL(20,6) NOT NULL DEFAULT 0,
ctr DECIMAL(20,8) NOT NULL DEFAULT 0,
cpc DECIMAL(20,8) NOT NULL DEFAULT 0,
cpm DECIMAL(20,8) NOT NULL DEFAULT 0,
conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
cpp DECIMAL(20,8) NOT NULL DEFAULT 0,
video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0,
avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0,
video_interaction_count DECIMAL(20,6) NOT NULL DEFAULT 0,
game_download_count DECIMAL(20,6) NOT NULL DEFAULT 0,
app_download_count DECIMAL(20,6) NOT NULL DEFAULT 0,
app_install_count DECIMAL(20,6) NOT NULL DEFAULT 0,
onsite_leads_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0,
hour VARCHAR(2) NOT NULL DEFAULT '',
day VARCHAR(10) NOT NULL DEFAULT '',
datasource VARCHAR(64) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
COMMENT ON TABLE creative_report_sum IS '创意报告汇总表';
COMMENT ON COLUMN creative_report_sum.id IS '主键ID';
COMMENT ON COLUMN creative_report_sum.tenant_id IS '租户ID';
COMMENT ON COLUMN creative_report_sum.creator IS '创建人';
COMMENT ON COLUMN creative_report_sum.created_at IS '创建时间';
COMMENT ON COLUMN creative_report_sum.updater IS '更新人';
COMMENT ON COLUMN creative_report_sum.updated_at IS '更新时间';
COMMENT ON COLUMN creative_report_sum.deleted_at IS '软删除时间';
COMMENT ON COLUMN creative_report_sum.cid IS '广告账户ID';
COMMENT ON COLUMN creative_report_sum.campaign_id IS '广告系列ID';
COMMENT ON COLUMN creative_report_sum.adgroup_id IS '广告组ID';
COMMENT ON COLUMN creative_report_sum.ad_id IS '创意ID';
COMMENT ON COLUMN creative_report_sum.ad_name IS '创意名称';
COMMENT ON COLUMN creative_report_sum.render_mode IS '创意类型';
COMMENT ON COLUMN creative_report_sum.inventory_type IS '投放位置';
COMMENT ON COLUMN creative_report_sum.promotion_target_id IS '推广目标ID';
COMMENT ON COLUMN creative_report_sum.impression IS '展示数';
COMMENT ON COLUMN creative_report_sum.click IS '点击数';
COMMENT ON COLUMN creative_report_sum.cost IS '花费(元)';
COMMENT ON COLUMN creative_report_sum.ctr IS '点击率';
COMMENT ON COLUMN creative_report_sum.cpc IS '平均点击价格';
COMMENT ON COLUMN creative_report_sum.cpm IS '千次展现成本';
COMMENT ON COLUMN creative_report_sum.conversion IS '转化数';
COMMENT ON COLUMN creative_report_sum.conversion_rate IS '转化率';
COMMENT ON COLUMN creative_report_sum.cpp IS '单次转化成本';
COMMENT ON COLUMN creative_report_sum.video_play_count IS '视频播放次数';
COMMENT ON COLUMN creative_report_sum.video_play_uv IS '视频播放人数';
COMMENT ON COLUMN creative_report_sum.avg_video_play_duration IS '平均播放时长(秒)';
COMMENT ON COLUMN creative_report_sum.video_interaction_count IS '视频互动数';
COMMENT ON COLUMN creative_report_sum.game_download_count IS '游戏下载数';
COMMENT ON COLUMN creative_report_sum.app_download_count IS '应用下载数';
COMMENT ON COLUMN creative_report_sum.app_install_count IS '应用安装数';
COMMENT ON COLUMN creative_report_sum.onsite_leads_count IS '预注册数';
COMMENT ON COLUMN creative_report_sum.deep_convert_count IS '深度转化数';
COMMENT ON COLUMN creative_report_sum.deep_convert_rate IS '深度转化率';
COMMENT ON COLUMN creative_report_sum.deep_convert_cost IS '深度转化成本';
COMMENT ON COLUMN creative_report_sum.hour IS '数据小时';
COMMENT ON COLUMN creative_report_sum.day IS '数据日期';
COMMENT ON COLUMN creative_report_sum.datasource IS '数据源';
CREATE INDEX idx_creative_report_sum_cid ON creative_report_sum(tenant_id, cid);
CREATE INDEX idx_creative_report_sum_campaign_id ON creative_report_sum(tenant_id, campaign_id);
CREATE INDEX idx_creative_report_sum_ad_id ON creative_report_sum(tenant_id, ad_id);
CREATE INDEX idx_creative_report_sum_day ON creative_report_sum(tenant_id, day);
CREATE INDEX idx_creative_report_sum_hour ON creative_report_sum(tenant_id, hour);
CREATE INDEX idx_creative_report_sum_datasource ON creative_report_sum(tenant_id, datasource);
CREATE UNIQUE INDEX idx_creative_report_sum_unique ON creative_report_sum(tenant_id, ad_id, hour, day, datasource);

View File

@@ -1,207 +0,0 @@
-- Unit Report Tables (单元报告表)
-- =============================================
-- 单元报告明细表 (unit_report_detail)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS unit_report_detail_id_seq;
CREATE TABLE IF NOT EXISTS unit_report_detail (
id BIGINT NOT NULL DEFAULT nextval('unit_report_detail_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
campaign_id VARCHAR(64) NOT NULL DEFAULT '',
adgroup_id VARCHAR(64) NOT NULL DEFAULT '',
adgroup_name VARCHAR(255) NOT NULL DEFAULT '',
marketing_target_id VARCHAR(64) NOT NULL DEFAULT '',
marketing_target_name VARCHAR(255) NOT NULL DEFAULT '',
placement_type VARCHAR(32) NOT NULL DEFAULT '',
inventory_type VARCHAR(32) NOT NULL DEFAULT '',
campaign_budget DECIMAL(20,6) NOT NULL DEFAULT 0,
adgroup_budget DECIMAL(20,6) NOT NULL DEFAULT 0,
bid_mode VARCHAR(32) NOT NULL DEFAULT '',
bid_amount DECIMAL(20,6) NOT NULL DEFAULT 0,
impression DECIMAL(20,6) NOT NULL DEFAULT 0,
click DECIMAL(20,6) NOT NULL DEFAULT 0,
cost DECIMAL(20,6) NOT NULL DEFAULT 0,
ctr DECIMAL(20,8) NOT NULL DEFAULT 0,
cpc DECIMAL(20,8) NOT NULL DEFAULT 0,
cpm DECIMAL(20,8) NOT NULL DEFAULT 0,
conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
cpp DECIMAL(20,8) NOT NULL DEFAULT 0,
primary_url VARCHAR(1024) NOT NULL DEFAULT '',
video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0,
avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0,
video_interaction_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_engage_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_share_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_comment_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_like_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_repost_count DECIMAL(20,6) NOT NULL DEFAULT 0,
game_download_count DECIMAL(20,6) NOT NULL DEFAULT 0,
app_download_count DECIMAL(20,6) NOT NULL DEFAULT 0,
app_install_count DECIMAL(20,6) NOT NULL DEFAULT 0,
onsite_leads_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0,
day VARCHAR(10) NOT NULL DEFAULT '',
datasource VARCHAR(64) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
COMMENT ON TABLE unit_report_detail IS '单元报告明细表';
COMMENT ON COLUMN unit_report_detail.id IS '主键ID';
COMMENT ON COLUMN unit_report_detail.tenant_id IS '租户ID';
COMMENT ON COLUMN unit_report_detail.creator IS '创建人';
COMMENT ON COLUMN unit_report_detail.created_at IS '创建时间';
COMMENT ON COLUMN unit_report_detail.updater IS '更新人';
COMMENT ON COLUMN unit_report_detail.updated_at IS '更新时间';
COMMENT ON COLUMN unit_report_detail.deleted_at IS '软删除时间';
COMMENT ON COLUMN unit_report_detail.cid IS '广告账户ID';
COMMENT ON COLUMN unit_report_detail.campaign_id IS '广告系列ID';
COMMENT ON COLUMN unit_report_detail.adgroup_id IS '广告组ID';
COMMENT ON COLUMN unit_report_detail.adgroup_name IS '广告组名称';
COMMENT ON COLUMN unit_report_detail.marketing_target_id IS '营销标的ID';
COMMENT ON COLUMN unit_report_detail.marketing_target_name IS '营销标的名称';
COMMENT ON COLUMN unit_report_detail.placement_type IS '投放版位';
COMMENT ON COLUMN unit_report_detail.inventory_type IS '投放位置';
COMMENT ON COLUMN unit_report_detail.campaign_budget IS '广告系列预算';
COMMENT ON COLUMN unit_report_detail.adgroup_budget IS '广告组预算';
COMMENT ON COLUMN unit_report_detail.bid_mode IS '出价方式';
COMMENT ON COLUMN unit_report_detail.bid_amount IS '出价/代理出价';
COMMENT ON COLUMN unit_report_detail.impression IS '展示数';
COMMENT ON COLUMN unit_report_detail.click IS '点击数';
COMMENT ON COLUMN unit_report_detail.cost IS '花费(元)';
COMMENT ON COLUMN unit_report_detail.ctr IS '点击率';
COMMENT ON COLUMN unit_report_detail.cpc IS '平均点击价格';
COMMENT ON COLUMN unit_report_detail.cpm IS '千次展现成本';
COMMENT ON COLUMN unit_report_detail.conversion IS '转化数';
COMMENT ON COLUMN unit_report_detail.conversion_rate IS '转化率';
COMMENT ON COLUMN unit_report_detail.cpp IS '单次转化成本';
COMMENT ON COLUMN unit_report_detail.primary_url IS '落地页URL';
COMMENT ON COLUMN unit_report_detail.video_play_count IS '视频播放次数';
COMMENT ON COLUMN unit_report_detail.video_play_uv IS '视频播放人数';
COMMENT ON COLUMN unit_report_detail.avg_video_play_duration IS '平均播放时长(秒)';
COMMENT ON COLUMN unit_report_detail.video_interaction_count IS '视频互动数';
COMMENT ON COLUMN unit_report_detail.tweet_engage_count IS '推文参与数';
COMMENT ON COLUMN unit_report_detail.tweet_share_count IS '推文分享数';
COMMENT ON COLUMN unit_report_detail.tweet_comment_count IS '推文评论数';
COMMENT ON COLUMN unit_report_detail.tweet_like_count IS '推文点赞数';
COMMENT ON COLUMN unit_report_detail.tweet_repost_count IS '推文转发数';
COMMENT ON COLUMN unit_report_detail.game_download_count IS '游戏下载数';
COMMENT ON COLUMN unit_report_detail.app_download_count IS '应用下载数';
COMMENT ON COLUMN unit_report_detail.app_install_count IS '应用安装数';
COMMENT ON COLUMN unit_report_detail.onsite_leads_count IS '预注册数';
COMMENT ON COLUMN unit_report_detail.deep_convert_count IS '深度转化数';
COMMENT ON COLUMN unit_report_detail.deep_convert_rate IS '深度转化率';
COMMENT ON COLUMN unit_report_detail.deep_convert_cost IS '深度转化成本';
COMMENT ON COLUMN unit_report_detail.day IS '数据日期';
COMMENT ON COLUMN unit_report_detail.datasource IS '数据源';
CREATE INDEX idx_unit_report_detail_cid ON unit_report_detail(tenant_id, cid);
CREATE INDEX idx_unit_report_detail_campaign_id ON unit_report_detail(tenant_id, campaign_id);
CREATE INDEX idx_unit_report_detail_adgroup_id ON unit_report_detail(tenant_id, adgroup_id);
CREATE INDEX idx_unit_report_detail_day ON unit_report_detail(tenant_id, day);
CREATE INDEX idx_unit_report_detail_datasource ON unit_report_detail(tenant_id, datasource);
-- =============================================
-- 单元报告汇总表 (unit_report_sum)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS unit_report_sum_id_seq;
CREATE TABLE IF NOT EXISTS unit_report_sum (
id BIGINT NOT NULL DEFAULT nextval('unit_report_sum_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
campaign_id VARCHAR(64) NOT NULL DEFAULT '',
adgroup_id VARCHAR(64) NOT NULL DEFAULT '',
adgroup_name VARCHAR(255) NOT NULL DEFAULT '',
marketing_target_id VARCHAR(64) NOT NULL DEFAULT '',
marketing_target_name VARCHAR(255) NOT NULL DEFAULT '',
placement_type VARCHAR(32) NOT NULL DEFAULT '',
inventory_type VARCHAR(32) NOT NULL DEFAULT '',
impression DECIMAL(20,6) NOT NULL DEFAULT 0,
click DECIMAL(20,6) NOT NULL DEFAULT 0,
cost DECIMAL(20,6) NOT NULL DEFAULT 0,
ctr DECIMAL(20,8) NOT NULL DEFAULT 0,
cpc DECIMAL(20,8) NOT NULL DEFAULT 0,
cpm DECIMAL(20,8) NOT NULL DEFAULT 0,
conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
cpp DECIMAL(20,8) NOT NULL DEFAULT 0,
video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0,
avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0,
video_interaction_count DECIMAL(20,6) NOT NULL DEFAULT 0,
game_download_count DECIMAL(20,6) NOT NULL DEFAULT 0,
app_download_count DECIMAL(20,6) NOT NULL DEFAULT 0,
app_install_count DECIMAL(20,6) NOT NULL DEFAULT 0,
onsite_leads_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0,
hour VARCHAR(2) NOT NULL DEFAULT '',
day VARCHAR(10) NOT NULL DEFAULT '',
datasource VARCHAR(64) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
COMMENT ON TABLE unit_report_sum IS '单元报告汇总表';
COMMENT ON COLUMN unit_report_sum.id IS '主键ID';
COMMENT ON COLUMN unit_report_sum.tenant_id IS '租户ID';
COMMENT ON COLUMN unit_report_sum.creator IS '创建人';
COMMENT ON COLUMN unit_report_sum.created_at IS '创建时间';
COMMENT ON COLUMN unit_report_sum.updater IS '更新人';
COMMENT ON COLUMN unit_report_sum.updated_at IS '更新时间';
COMMENT ON COLUMN unit_report_sum.deleted_at IS '软删除时间';
COMMENT ON COLUMN unit_report_sum.cid IS '广告账户ID';
COMMENT ON COLUMN unit_report_sum.campaign_id IS '广告系列ID';
COMMENT ON COLUMN unit_report_sum.adgroup_id IS '广告组ID';
COMMENT ON COLUMN unit_report_sum.adgroup_name IS '广告组名称';
COMMENT ON COLUMN unit_report_sum.marketing_target_id IS '营销标的ID';
COMMENT ON COLUMN unit_report_sum.marketing_target_name IS '营销标的名称';
COMMENT ON COLUMN unit_report_sum.placement_type IS '投放版位';
COMMENT ON COLUMN unit_report_sum.inventory_type IS '投放位置';
COMMENT ON COLUMN unit_report_sum.impression IS '展示数';
COMMENT ON COLUMN unit_report_sum.click IS '点击数';
COMMENT ON COLUMN unit_report_sum.cost IS '花费(元)';
COMMENT ON COLUMN unit_report_sum.ctr IS '点击率';
COMMENT ON COLUMN unit_report_sum.cpc IS '平均点击价格';
COMMENT ON COLUMN unit_report_sum.cpm IS '千次展现成本';
COMMENT ON COLUMN unit_report_sum.conversion IS '转化数';
COMMENT ON COLUMN unit_report_sum.conversion_rate IS '转化率';
COMMENT ON COLUMN unit_report_sum.cpp IS '单次转化成本';
COMMENT ON COLUMN unit_report_sum.video_play_count IS '视频播放次数';
COMMENT ON COLUMN unit_report_sum.video_play_uv IS '视频播放人数';
COMMENT ON COLUMN unit_report_sum.avg_video_play_duration IS '平均播放时长(秒)';
COMMENT ON COLUMN unit_report_sum.video_interaction_count IS '视频互动数';
COMMENT ON COLUMN unit_report_sum.game_download_count IS '游戏下载数';
COMMENT ON COLUMN unit_report_sum.app_download_count IS '应用下载数';
COMMENT ON COLUMN unit_report_sum.app_install_count IS '应用安装数';
COMMENT ON COLUMN unit_report_sum.onsite_leads_count IS '预注册数';
COMMENT ON COLUMN unit_report_sum.deep_convert_count IS '深度转化数';
COMMENT ON COLUMN unit_report_sum.deep_convert_rate IS '深度转化率';
COMMENT ON COLUMN unit_report_sum.deep_convert_cost IS '深度转化成本';
COMMENT ON COLUMN unit_report_sum.hour IS '数据小时';
COMMENT ON COLUMN unit_report_sum.day IS '数据日期';
COMMENT ON COLUMN unit_report_sum.datasource IS '数据源';
CREATE INDEX idx_unit_report_sum_cid ON unit_report_sum(tenant_id, cid);
CREATE INDEX idx_unit_report_sum_campaign_id ON unit_report_sum(tenant_id, campaign_id);
CREATE INDEX idx_unit_report_sum_adgroup_id ON unit_report_sum(tenant_id, adgroup_id);
CREATE INDEX idx_unit_report_sum_day ON unit_report_sum(tenant_id, day);
CREATE INDEX idx_unit_report_sum_hour ON unit_report_sum(tenant_id, hour);
CREATE INDEX idx_unit_report_sum_datasource ON unit_report_sum(tenant_id, datasource);
CREATE UNIQUE INDEX idx_unit_report_sum_unique ON unit_report_sum(tenant_id, adgroup_id, hour, day, datasource);

View File

@@ -1,177 +0,0 @@
-- Storewide Report Tables (全店报告表)
-- =============================================
-- 全店报告明细表 (storewide_report_detail)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS storewide_report_detail_id_seq;
CREATE TABLE IF NOT EXISTS storewide_report_detail (
id BIGINT NOT NULL DEFAULT nextval('storewide_report_detail_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
campaign_id VARCHAR(64) NOT NULL DEFAULT '',
adgroup_id VARCHAR(64) NOT NULL DEFAULT '',
ad_id VARCHAR(64) NOT NULL DEFAULT '',
ad_name VARCHAR(255) NOT NULL DEFAULT '',
primary_url VARCHAR(1024) NOT NULL DEFAULT '',
impression DECIMAL(20,6) NOT NULL DEFAULT 0,
click DECIMAL(20,6) NOT NULL DEFAULT 0,
cost DECIMAL(20,6) NOT NULL DEFAULT 0,
ctr DECIMAL(20,8) NOT NULL DEFAULT 0,
cpc DECIMAL(20,8) NOT NULL DEFAULT 0,
cpm DECIMAL(20,8) NOT NULL DEFAULT 0,
direct_conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
indirect_conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
cpp DECIMAL(20,8) NOT NULL DEFAULT 0,
roe DECIMAL(20,8) NOT NULL DEFAULT 0,
gmv DECIMAL(20,6) NOT NULL DEFAULT 0,
order_count DECIMAL(20,6) NOT NULL DEFAULT 0,
avg_order_price DECIMAL(20,8) NOT NULL DEFAULT 0,
cart_count DECIMAL(20,6) NOT NULL DEFAULT 0,
favorite_count DECIMAL(20,6) NOT NULL DEFAULT 0,
page_view DECIMAL(20,6) NOT NULL DEFAULT 0,
browse_duration DECIMAL(20,6) NOT NULL DEFAULT 0,
avg_browse_duration DECIMAL(20,6) NOT NULL DEFAULT 0,
day VARCHAR(10) NOT NULL DEFAULT '',
datasource VARCHAR(64) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
COMMENT ON TABLE storewide_report_detail IS '全店报告明细表';
COMMENT ON COLUMN storewide_report_detail.id IS '主键ID';
COMMENT ON COLUMN storewide_report_detail.tenant_id IS '租户ID';
COMMENT ON COLUMN storewide_report_detail.creator IS '创建人';
COMMENT ON COLUMN storewide_report_detail.created_at IS '创建时间';
COMMENT ON COLUMN storewide_report_detail.updater IS '更新人';
COMMENT ON COLUMN storewide_report_detail.updated_at IS '更新时间';
COMMENT ON COLUMN storewide_report_detail.deleted_at IS '软删除时间';
COMMENT ON COLUMN storewide_report_detail.cid IS '广告账户ID';
COMMENT ON COLUMN storewide_report_detail.campaign_id IS '广告系列ID';
COMMENT ON COLUMN storewide_report_detail.adgroup_id IS '广告组ID';
COMMENT ON COLUMN storewide_report_detail.ad_id IS '创意ID';
COMMENT ON COLUMN storewide_report_detail.ad_name IS '创意名称';
COMMENT ON COLUMN storewide_report_detail.primary_url IS '落地页URL';
COMMENT ON COLUMN storewide_report_detail.impression IS '展示数';
COMMENT ON COLUMN storewide_report_detail.click IS '点击数';
COMMENT ON COLUMN storewide_report_detail.cost IS '花费(元)';
COMMENT ON COLUMN storewide_report_detail.ctr IS '点击率';
COMMENT ON COLUMN storewide_report_detail.cpc IS '平均点击价格';
COMMENT ON COLUMN storewide_report_detail.cpm IS '千次展现成本';
COMMENT ON COLUMN storewide_report_detail.direct_conversion IS '直接转化数';
COMMENT ON COLUMN storewide_report_detail.indirect_conversion IS '间接转化数';
COMMENT ON COLUMN storewide_report_detail.conversion IS '总转化数';
COMMENT ON COLUMN storewide_report_detail.conversion_rate IS '转化率';
COMMENT ON COLUMN storewide_report_detail.cpp IS '单次转化成本';
COMMENT ON COLUMN storewide_report_detail.roe IS '投资回报率(ROE)';
COMMENT ON COLUMN storewide_report_detail.gmv IS 'GMV(元)';
COMMENT ON COLUMN storewide_report_detail.order_count IS '订单数';
COMMENT ON COLUMN storewide_report_detail.avg_order_price IS '平均客单价';
COMMENT ON COLUMN storewide_report_detail.cart_count IS '加购数';
COMMENT ON COLUMN storewide_report_detail.favorite_count IS '收藏数';
COMMENT ON COLUMN storewide_report_detail.page_view IS '页面浏览数';
COMMENT ON COLUMN storewide_report_detail.browse_duration IS '浏览时长';
COMMENT ON COLUMN storewide_report_detail.avg_browse_duration IS '平均浏览时长(秒)';
COMMENT ON COLUMN storewide_report_detail.day IS '数据日期';
COMMENT ON COLUMN storewide_report_detail.datasource IS '数据源';
CREATE INDEX idx_storewide_report_detail_cid ON storewide_report_detail(tenant_id, cid);
CREATE INDEX idx_storewide_report_detail_campaign_id ON storewide_report_detail(tenant_id, campaign_id);
CREATE INDEX idx_storewide_report_detail_ad_id ON storewide_report_detail(tenant_id, ad_id);
CREATE INDEX idx_storewide_report_detail_day ON storewide_report_detail(tenant_id, day);
CREATE INDEX idx_storewide_report_detail_datasource ON storewide_report_detail(tenant_id, datasource);
-- =============================================
-- 全店报告汇总表 (storewide_report_sum)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS storewide_report_sum_id_seq;
CREATE TABLE IF NOT EXISTS storewide_report_sum (
id BIGINT NOT NULL DEFAULT nextval('storewide_report_sum_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
campaign_id VARCHAR(64) NOT NULL DEFAULT '',
adgroup_id VARCHAR(64) NOT NULL DEFAULT '',
ad_id VARCHAR(64) NOT NULL DEFAULT '',
ad_name VARCHAR(255) NOT NULL DEFAULT '',
impression DECIMAL(20,6) NOT NULL DEFAULT 0,
click DECIMAL(20,6) NOT NULL DEFAULT 0,
cost DECIMAL(20,6) NOT NULL DEFAULT 0,
ctr DECIMAL(20,8) NOT NULL DEFAULT 0,
cpc DECIMAL(20,8) NOT NULL DEFAULT 0,
cpm DECIMAL(20,8) NOT NULL DEFAULT 0,
direct_conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
indirect_conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
cpp DECIMAL(20,8) NOT NULL DEFAULT 0,
roe DECIMAL(20,8) NOT NULL DEFAULT 0,
gmv DECIMAL(20,6) NOT NULL DEFAULT 0,
order_count DECIMAL(20,6) NOT NULL DEFAULT 0,
avg_order_price DECIMAL(20,8) NOT NULL DEFAULT 0,
cart_count DECIMAL(20,6) NOT NULL DEFAULT 0,
favorite_count DECIMAL(20,6) NOT NULL DEFAULT 0,
page_view DECIMAL(20,6) NOT NULL DEFAULT 0,
browse_duration DECIMAL(20,6) NOT NULL DEFAULT 0,
avg_browse_duration DECIMAL(20,6) NOT NULL DEFAULT 0,
hour VARCHAR(2) NOT NULL DEFAULT '',
day VARCHAR(10) NOT NULL DEFAULT '',
datasource VARCHAR(64) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
COMMENT ON TABLE storewide_report_sum IS '全店报告汇总表';
COMMENT ON COLUMN storewide_report_sum.id IS '主键ID';
COMMENT ON COLUMN storewide_report_sum.tenant_id IS '租户ID';
COMMENT ON COLUMN storewide_report_sum.creator IS '创建人';
COMMENT ON COLUMN storewide_report_sum.created_at IS '创建时间';
COMMENT ON COLUMN storewide_report_sum.updater IS '更新人';
COMMENT ON COLUMN storewide_report_sum.updated_at IS '更新时间';
COMMENT ON COLUMN storewide_report_sum.deleted_at IS '软删除时间';
COMMENT ON COLUMN storewide_report_sum.cid IS '广告账户ID';
COMMENT ON COLUMN storewide_report_sum.campaign_id IS '广告系列ID';
COMMENT ON COLUMN storewide_report_sum.adgroup_id IS '广告组ID';
COMMENT ON COLUMN storewide_report_sum.ad_id IS '创意ID';
COMMENT ON COLUMN storewide_report_sum.ad_name IS '创意名称';
COMMENT ON COLUMN storewide_report_sum.impression IS '展示数';
COMMENT ON COLUMN storewide_report_sum.click IS '点击数';
COMMENT ON COLUMN storewide_report_sum.cost IS '花费(元)';
COMMENT ON COLUMN storewide_report_sum.ctr IS '点击率';
COMMENT ON COLUMN storewide_report_sum.cpc IS '平均点击价格';
COMMENT ON COLUMN storewide_report_sum.cpm IS '千次展现成本';
COMMENT ON COLUMN storewide_report_sum.direct_conversion IS '直接转化数';
COMMENT ON COLUMN storewide_report_sum.indirect_conversion IS '间接转化数';
COMMENT ON COLUMN storewide_report_sum.conversion IS '总转化数';
COMMENT ON COLUMN storewide_report_sum.conversion_rate IS '转化率';
COMMENT ON COLUMN storewide_report_sum.cpp IS '单次转化成本';
COMMENT ON COLUMN storewide_report_sum.roe IS '投资回报率(ROE)';
COMMENT ON COLUMN storewide_report_sum.gmv IS 'GMV(元)';
COMMENT ON COLUMN storewide_report_sum.order_count IS '订单数';
COMMENT ON COLUMN storewide_report_sum.avg_order_price IS '平均客单价';
COMMENT ON COLUMN storewide_report_sum.cart_count IS '加购数';
COMMENT ON COLUMN storewide_report_sum.favorite_count IS '收藏数';
COMMENT ON COLUMN storewide_report_sum.page_view IS '页面浏览数';
COMMENT ON COLUMN storewide_report_sum.browse_duration IS '浏览时长';
COMMENT ON COLUMN storewide_report_sum.avg_browse_duration IS '平均浏览时长(秒)';
COMMENT ON COLUMN storewide_report_sum.hour IS '数据小时';
COMMENT ON COLUMN storewide_report_sum.day IS '数据日期';
COMMENT ON COLUMN storewide_report_sum.datasource IS '数据源';
CREATE INDEX idx_storewide_report_sum_cid ON storewide_report_sum(tenant_id, cid);
CREATE INDEX idx_storewide_report_sum_campaign_id ON storewide_report_sum(tenant_id, campaign_id);
CREATE INDEX idx_storewide_report_sum_ad_id ON storewide_report_sum(tenant_id, ad_id);
CREATE INDEX idx_storewide_report_sum_day ON storewide_report_sum(tenant_id, day);
CREATE INDEX idx_storewide_report_sum_hour ON storewide_report_sum(tenant_id, hour);
CREATE INDEX idx_storewide_report_sum_datasource ON storewide_report_sum(tenant_id, datasource);
CREATE UNIQUE INDEX idx_storewide_report_sum_unique ON storewide_report_sum(tenant_id, ad_id, hour, day, datasource);

View File

@@ -1,184 +0,0 @@
-- Material and Population Report Tables (素材报告和人群报告表)
-- =============================================
-- 素材报告表 (material_report)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS material_report_id_seq;
CREATE TABLE IF NOT EXISTS material_report (
id BIGINT NOT NULL DEFAULT nextval('material_report_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
ad_id VARCHAR(64) NOT NULL DEFAULT '',
ad_name VARCHAR(255) NOT NULL DEFAULT '',
material_hash VARCHAR(128) NOT NULL DEFAULT '',
material_url VARCHAR(2048) NOT NULL DEFAULT '',
material_type VARCHAR(32) NOT NULL DEFAULT '',
impression DECIMAL(20,6) NOT NULL DEFAULT 0,
click DECIMAL(20,6) NOT NULL DEFAULT 0,
cost DECIMAL(20,6) NOT NULL DEFAULT 0,
ctr DECIMAL(20,8) NOT NULL DEFAULT 0,
cpc DECIMAL(20,8) NOT NULL DEFAULT 0,
cpm DECIMAL(20,8) NOT NULL DEFAULT 0,
conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
cpp DECIMAL(20,8) NOT NULL DEFAULT 0,
video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0,
avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0,
video_three_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
video_five_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0,
day VARCHAR(10) NOT NULL DEFAULT '',
datasource VARCHAR(64) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
COMMENT ON TABLE material_report IS '素材报告表';
COMMENT ON COLUMN material_report.id IS '主键ID';
COMMENT ON COLUMN material_report.tenant_id IS '租户ID';
COMMENT ON COLUMN material_report.creator IS '创建人';
COMMENT ON COLUMN material_report.created_at IS '创建时间';
COMMENT ON COLUMN material_report.updater IS '更新人';
COMMENT ON COLUMN material_report.updated_at IS '更新时间';
COMMENT ON COLUMN material_report.deleted_at IS '软删除时间';
COMMENT ON COLUMN material_report.cid IS '广告账户ID';
COMMENT ON COLUMN material_report.ad_id IS '创意ID';
COMMENT ON COLUMN material_report.ad_name IS '创意名称';
COMMENT ON COLUMN material_report.material_hash IS '素材哈希';
COMMENT ON COLUMN material_report.material_url IS '素材URL';
COMMENT ON COLUMN material_report.material_type IS '素材类型';
COMMENT ON COLUMN material_report.impression IS '展示数';
COMMENT ON COLUMN material_report.click IS '点击数';
COMMENT ON COLUMN material_report.cost IS '花费(元)';
COMMENT ON COLUMN material_report.ctr IS '点击率';
COMMENT ON COLUMN material_report.cpc IS '平均点击价格';
COMMENT ON COLUMN material_report.cpm IS '千次展现成本';
COMMENT ON COLUMN material_report.conversion IS '转化数';
COMMENT ON COLUMN material_report.conversion_rate IS '转化率';
COMMENT ON COLUMN material_report.cpp IS '单次转化成本';
COMMENT ON COLUMN material_report.video_play_count IS '视频播放次数';
COMMENT ON COLUMN material_report.video_play_uv IS '视频播放人数';
COMMENT ON COLUMN material_report.avg_video_play_duration IS '平均播放时长(秒)';
COMMENT ON COLUMN material_report.video_three_second_play_count IS '视频3秒播放次数';
COMMENT ON COLUMN material_report.video_five_second_play_count IS '视频5秒播放次数';
COMMENT ON COLUMN material_report.deep_convert_count IS '深度转化数';
COMMENT ON COLUMN material_report.deep_convert_rate IS '深度转化率';
COMMENT ON COLUMN material_report.deep_convert_cost IS '深度转化成本';
COMMENT ON COLUMN material_report.day IS '数据日期';
COMMENT ON COLUMN material_report.datasource IS '数据源';
CREATE INDEX idx_material_report_cid ON material_report(tenant_id, cid);
CREATE INDEX idx_material_report_ad_id ON material_report(tenant_id, ad_id);
CREATE INDEX idx_material_report_material_hash ON material_report(tenant_id, material_hash);
CREATE INDEX idx_material_report_day ON material_report(tenant_id, day);
CREATE INDEX idx_material_report_datasource ON material_report(tenant_id, datasource);
-- =============================================
-- 人群报告表 (population_report)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS population_report_id_seq;
CREATE TABLE IF NOT EXISTS population_report (
id BIGINT NOT NULL DEFAULT nextval('population_report_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
deleted_at TIMESTAMP WITH TIME ZONE,
cid VARCHAR(64) NOT NULL DEFAULT '',
campaign_id VARCHAR(64) NOT NULL DEFAULT '',
adgroup_id VARCHAR(64) NOT NULL DEFAULT '',
audience_template_id VARCHAR(64) NOT NULL DEFAULT '',
audience_template_name VARCHAR(255) NOT NULL DEFAULT '',
audience_type VARCHAR(32) NOT NULL DEFAULT '',
audience_source VARCHAR(32) NOT NULL DEFAULT '',
impression DECIMAL(20,6) NOT NULL DEFAULT 0,
click DECIMAL(20,6) NOT NULL DEFAULT 0,
cost DECIMAL(20,6) NOT NULL DEFAULT 0,
ctr DECIMAL(20,8) NOT NULL DEFAULT 0,
cpc DECIMAL(20,8) NOT NULL DEFAULT 0,
cpm DECIMAL(20,8) NOT NULL DEFAULT 0,
conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
cpp DECIMAL(20,8) NOT NULL DEFAULT 0,
video_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
video_play_uv DECIMAL(20,6) NOT NULL DEFAULT 0,
avg_video_play_duration DECIMAL(20,6) NOT NULL DEFAULT 0,
video_three_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
video_five_second_play_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_engage_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_share_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_comment_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_like_count DECIMAL(20,6) NOT NULL DEFAULT 0,
tweet_repost_count DECIMAL(20,6) NOT NULL DEFAULT 0,
game_download_count DECIMAL(20,6) NOT NULL DEFAULT 0,
app_download_count DECIMAL(20,6) NOT NULL DEFAULT 0,
app_install_count DECIMAL(20,6) NOT NULL DEFAULT 0,
onsite_leads_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_count DECIMAL(20,6) NOT NULL DEFAULT 0,
deep_convert_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
deep_convert_cost DECIMAL(20,8) NOT NULL DEFAULT 0,
day VARCHAR(10) NOT NULL DEFAULT '',
datasource VARCHAR(64) NOT NULL DEFAULT '',
PRIMARY KEY (id)
);
COMMENT ON TABLE population_report IS '人群报告表';
COMMENT ON COLUMN population_report.id IS '主键ID';
COMMENT ON COLUMN population_report.tenant_id IS '租户ID';
COMMENT ON COLUMN population_report.creator IS '创建人';
COMMENT ON COLUMN population_report.created_at IS '创建时间';
COMMENT ON COLUMN population_report.updater IS '更新人';
COMMENT ON COLUMN population_report.updated_at IS '更新时间';
COMMENT ON COLUMN population_report.deleted_at IS '软删除时间';
COMMENT ON COLUMN population_report.cid IS '广告账户ID';
COMMENT ON COLUMN population_report.campaign_id IS '广告系列ID';
COMMENT ON COLUMN population_report.adgroup_id IS '广告组ID';
COMMENT ON COLUMN population_report.audience_template_id IS '人群包ID';
COMMENT ON COLUMN population_report.audience_template_name IS '人群包名称';
COMMENT ON COLUMN population_report.audience_type IS '人群类型';
COMMENT ON COLUMN population_report.audience_source IS '人群来源';
COMMENT ON COLUMN population_report.impression IS '展示数';
COMMENT ON COLUMN population_report.click IS '点击数';
COMMENT ON COLUMN population_report.cost IS '花费(元)';
COMMENT ON COLUMN population_report.ctr IS '点击率';
COMMENT ON COLUMN population_report.cpc IS '平均点击价格';
COMMENT ON COLUMN population_report.cpm IS '千次展现成本';
COMMENT ON COLUMN population_report.conversion IS '转化数';
COMMENT ON COLUMN population_report.conversion_rate IS '转化率';
COMMENT ON COLUMN population_report.cpp IS '单次转化成本';
COMMENT ON COLUMN population_report.video_play_count IS '视频播放次数';
COMMENT ON COLUMN population_report.video_play_uv IS '视频播放人数';
COMMENT ON COLUMN population_report.avg_video_play_duration IS '平均播放时长(秒)';
COMMENT ON COLUMN population_report.video_three_second_play_count IS '视频3秒播放次数';
COMMENT ON COLUMN population_report.video_five_second_play_count IS '视频5秒播放次数';
COMMENT ON COLUMN population_report.tweet_engage_count IS '推文参与数';
COMMENT ON COLUMN population_report.tweet_share_count IS '推文分享数';
COMMENT ON COLUMN population_report.tweet_comment_count IS '推文评论数';
COMMENT ON COLUMN population_report.tweet_like_count IS '推文点赞数';
COMMENT ON COLUMN population_report.tweet_repost_count IS '推文转发数';
COMMENT ON COLUMN population_report.game_download_count IS '游戏下载数';
COMMENT ON COLUMN population_report.app_download_count IS '应用下载数';
COMMENT ON COLUMN population_report.app_install_count IS '应用安装数';
COMMENT ON COLUMN population_report.onsite_leads_count IS '预注册数';
COMMENT ON COLUMN population_report.deep_convert_count IS '深度转化数';
COMMENT ON COLUMN population_report.deep_convert_rate IS '深度转化率';
COMMENT ON COLUMN population_report.deep_convert_cost IS '深度转化成本';
COMMENT ON COLUMN population_report.day IS '数据日期';
COMMENT ON COLUMN population_report.datasource IS '数据源';
CREATE INDEX idx_population_report_cid ON population_report(tenant_id, cid);
CREATE INDEX idx_population_report_campaign_id ON population_report(tenant_id, campaign_id);
CREATE INDEX idx_population_report_adgroup_id ON population_report(tenant_id, adgroup_id);
CREATE INDEX idx_population_report_audience_template_id ON population_report(tenant_id, audience_template_id);
CREATE INDEX idx_population_report_day ON population_report(tenant_id, day);
CREATE INDEX idx_population_report_datasource ON population_report(tenant_id, datasource);

View File

@@ -1,120 +0,0 @@
-- Sync Task and Task Report Tables (同步任务日志和任务报告表)
-- =============================================
-- 同步任务日志表 (sync_task_log)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS sync_task_log_id_seq;
CREATE TABLE IF NOT EXISTS sync_task_log (
id BIGINT NOT NULL DEFAULT nextval('sync_task_log_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
deleted_at TIMESTAMP WITH TIME ZONE,
task_id BIGINT NOT NULL DEFAULT 0,
report_type VARCHAR(64) NOT NULL DEFAULT '',
report_date VARCHAR(10) NOT NULL DEFAULT '',
cid VARCHAR(64) NOT NULL DEFAULT '',
campaign_id VARCHAR(64) NOT NULL DEFAULT '',
adgroup_id VARCHAR(64) NOT NULL DEFAULT '',
ad_id VARCHAR(64) NOT NULL DEFAULT '',
datasource VARCHAR(64) NOT NULL DEFAULT '',
sync_status VARCHAR(32) NOT NULL DEFAULT '',
error_message TEXT NOT NULL DEFAULT '',
start_time TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
end_time TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
PRIMARY KEY (id)
);
COMMENT ON TABLE sync_task_log IS '同步任务日志表';
COMMENT ON COLUMN sync_task_log.id IS '主键ID';
COMMENT ON COLUMN sync_task_log.tenant_id IS '租户ID';
COMMENT ON COLUMN sync_task_log.creator IS '创建人';
COMMENT ON COLUMN sync_task_log.created_at IS '创建时间';
COMMENT ON COLUMN sync_task_log.updater IS '更新人';
COMMENT ON COLUMN sync_task_log.updated_at IS '更新时间';
COMMENT ON COLUMN sync_task_log.deleted_at IS '软删除时间';
COMMENT ON COLUMN sync_task_log.task_id IS '调控任务ID';
COMMENT ON COLUMN sync_task_log.report_type IS '报告类型';
COMMENT ON COLUMN sync_task_log.report_date IS '报告日期';
COMMENT ON COLUMN sync_task_log.cid IS '广告账户ID';
COMMENT ON COLUMN sync_task_log.campaign_id IS '广告系列ID';
COMMENT ON COLUMN sync_task_log.adgroup_id IS '广告组ID';
COMMENT ON COLUMN sync_task_log.ad_id IS '创意ID';
COMMENT ON COLUMN sync_task_log.datasource IS '数据源';
COMMENT ON COLUMN sync_task_log.sync_status IS '同步状态';
COMMENT ON COLUMN sync_task_log.error_message IS '错误信息';
COMMENT ON COLUMN sync_task_log.start_time IS '开始时间';
COMMENT ON COLUMN sync_task_log.end_time IS '结束时间';
CREATE INDEX idx_sync_task_log_task_id ON sync_task_log(tenant_id, task_id);
CREATE INDEX idx_sync_task_log_report_type ON sync_task_log(tenant_id, report_type);
CREATE INDEX idx_sync_task_log_report_date ON sync_task_log(tenant_id, report_date);
CREATE INDEX idx_sync_task_log_cid ON sync_task_log(tenant_id, cid);
CREATE INDEX idx_sync_task_log_datasource ON sync_task_log(tenant_id, datasource);
CREATE INDEX idx_sync_task_log_sync_status ON sync_task_log(tenant_id, sync_status);
CREATE INDEX idx_sync_task_log_created_at ON sync_task_log(tenant_id, created_at);
-- =============================================
-- 调控任务报告表 (task_report)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS task_report_id_seq;
CREATE TABLE IF NOT EXISTS task_report (
id BIGINT NOT NULL DEFAULT nextval('task_report_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT '0001-01-01 00:00:00+00:00',
deleted_at TIMESTAMP WITH TIME ZONE,
task_id BIGINT NOT NULL DEFAULT 0,
datasource VARCHAR(64) NOT NULL DEFAULT '',
report_date VARCHAR(10) NOT NULL DEFAULT '',
total_count BIGINT NOT NULL DEFAULT 0,
success_count BIGINT NOT NULL DEFAULT 0,
fail_count BIGINT NOT NULL DEFAULT 0,
skip_count BIGINT NOT NULL DEFAULT 0,
total_cost DECIMAL(20,6) NOT NULL DEFAULT 0,
total_impression DECIMAL(20,6) NOT NULL DEFAULT 0,
total_click DECIMAL(20,6) NOT NULL DEFAULT 0,
total_conversion DECIMAL(20,6) NOT NULL DEFAULT 0,
avg_ctr DECIMAL(20,8) NOT NULL DEFAULT 0,
avg_cpc DECIMAL(20,8) NOT NULL DEFAULT 0,
avg_cpm DECIMAL(20,8) NOT NULL DEFAULT 0,
avg_conversion_rate DECIMAL(20,8) NOT NULL DEFAULT 0,
avg_cpp DECIMAL(20,8) NOT NULL DEFAULT 0,
PRIMARY KEY (id)
);
COMMENT ON TABLE task_report IS '调控任务报告表';
COMMENT ON COLUMN task_report.id IS '主键ID';
COMMENT ON COLUMN task_report.tenant_id IS '租户ID';
COMMENT ON COLUMN task_report.creator IS '创建人';
COMMENT ON COLUMN task_report.created_at IS '创建时间';
COMMENT ON COLUMN task_report.updater IS '更新人';
COMMENT ON COLUMN task_report.updated_at IS '更新时间';
COMMENT ON COLUMN task_report.deleted_at IS '软删除时间';
COMMENT ON COLUMN task_report.task_id IS '调控任务ID';
COMMENT ON COLUMN task_report.datasource IS '数据源';
COMMENT ON COLUMN task_report.report_date IS '报告日期';
COMMENT ON COLUMN task_report.total_count IS '总数量';
COMMENT ON COLUMN task_report.success_count IS '成功数量';
COMMENT ON COLUMN task_report.fail_count IS '失败数量';
COMMENT ON COLUMN task_report.skip_count IS '跳过数量';
COMMENT ON COLUMN task_report.total_cost IS '总花费(元)';
COMMENT ON COLUMN task_report.total_impression IS '总展示数';
COMMENT ON COLUMN task_report.total_click IS '总点击数';
COMMENT ON COLUMN task_report.total_conversion IS '总转化数';
COMMENT ON COLUMN task_report.avg_ctr IS '平均点击率';
COMMENT ON COLUMN task_report.avg_cpc IS '平均点击价格';
COMMENT ON COLUMN task_report.avg_cpm IS '平均千次展现成本';
COMMENT ON COLUMN task_report.avg_conversion_rate IS '平均转化率';
COMMENT ON COLUMN task_report.avg_cpp IS '平均单次转化成本';
CREATE INDEX idx_task_report_task_id ON task_report(tenant_id, task_id);
CREATE INDEX idx_task_report_datasource ON task_report(tenant_id, datasource);
CREATE INDEX idx_task_report_report_date ON task_report(tenant_id, report_date);
CREATE UNIQUE INDEX idx_task_report_unique ON task_report(tenant_id, task_id, datasource, report_date);

View File

@@ -1,41 +0,0 @@
-- 腾讯广告账户关系表
CREATE SEQUENCE IF NOT EXISTS tencent_account_relation_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS tencent_account_relation (
id BIGINT NOT NULL DEFAULT nextval('tencent_account_relation_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
-- 业务字段
account_id BIGINT NOT NULL,
corporation_name VARCHAR(500),
comment_data_list JSONB,
is_adx BOOLEAN DEFAULT FALSE,
is_bid BOOLEAN DEFAULT FALSE,
is_mp BOOLEAN DEFAULT FALSE,
PRIMARY KEY (id)
);
COMMENT ON TABLE tencent_account_relation IS '腾讯广告账户关系表';
COMMENT ON COLUMN tencent_account_relation.id IS '主键ID';
COMMENT ON COLUMN tencent_account_relation.tenant_id IS '租户ID';
COMMENT ON COLUMN tencent_account_relation.creator IS '创建人';
COMMENT ON COLUMN tencent_account_relation.created_at IS '创建时间';
COMMENT ON COLUMN tencent_account_relation.updater IS '更新人';
COMMENT ON COLUMN tencent_account_relation.updated_at IS '更新时间';
COMMENT ON COLUMN tencent_account_relation.deleted_at IS '软删除时间';
COMMENT ON COLUMN tencent_account_relation.account_id IS '账户ID';
COMMENT ON COLUMN tencent_account_relation.corporation_name IS '公司名称';
COMMENT ON COLUMN tencent_account_relation.comment_data_list IS '备注数据列表';
COMMENT ON COLUMN tencent_account_relation.is_adx IS '是否ADX';
COMMENT ON COLUMN tencent_account_relation.is_bid IS '是否BID';
COMMENT ON COLUMN tencent_account_relation.is_mp IS '是否MP';
-- 唯一索引根据account_id判断是否存在
CREATE UNIQUE INDEX idx_tencent_account_relation_account_id ON tencent_account_relation(tenant_id, account_id);
CREATE INDEX idx_tencent_account_relation_corporation ON tencent_account_relation(tenant_id, corporation_name);

View File

@@ -1,51 +0,0 @@
-- 腾讯广告音乐素材表
CREATE SEQUENCE IF NOT EXISTS tencent_audio_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS tencent_audio (
id BIGINT NOT NULL DEFAULT nextval('tencent_audio_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
-- 业务字段
audio_id VARCHAR(100) NOT NULL,
cover_image_url TEXT,
audio_name VARCHAR(500),
author VARCHAR(200),
duration NUMERIC(10, 2),
expire_time BIGINT,
feel_tags JSONB,
genre_tags JSONB,
-- 本地校验状态
verify_status VARCHAR(20) DEFAULT 'PENDING' NOT NULL, -- PENDING:待校验, VERIFIED:已校验, REJECTED:已拒绝
verified_at TIMESTAMP WITH TIME ZONE, -- 校验时间
verified_by VARCHAR(100), -- 校验人
PRIMARY KEY (id)
);
COMMENT ON TABLE tencent_audio IS '腾讯广告音乐素材表';
COMMENT ON COLUMN tencent_audio.id IS '主键ID';
COMMENT ON COLUMN tencent_audio.tenant_id IS '租户ID';
COMMENT ON COLUMN tencent_audio.creator IS '创建人';
COMMENT ON COLUMN tencent_audio.created_at IS '创建时间';
COMMENT ON COLUMN tencent_audio.updater IS '更新人';
COMMENT ON COLUMN tencent_audio.updated_at IS '更新时间';
COMMENT ON COLUMN tencent_audio.deleted_at IS '软删除时间';
COMMENT ON COLUMN tencent_audio.audio_id IS '音乐ID';
COMMENT ON COLUMN tencent_audio.cover_image_url IS '封面图片URL';
COMMENT ON COLUMN tencent_audio.audio_name IS '音乐名称';
COMMENT ON COLUMN tencent_audio.author IS '作者';
COMMENT ON COLUMN tencent_audio.duration IS '时长(秒)';
COMMENT ON COLUMN tencent_audio.expire_time IS '过期时间戳';
COMMENT ON COLUMN tencent_audio.feel_tags IS '情感标签数组';
COMMENT ON COLUMN tencent_audio.genre_tags IS '风格标签数组';
-- 唯一索引根据audio_id判断是否存在
CREATE UNIQUE INDEX idx_tencent_audio_audio_id ON tencent_audio(tenant_id, audio_id);
CREATE INDEX idx_tencent_audio_author ON tencent_audio(tenant_id, author);
CREATE INDEX idx_tencent_audio_expire_time ON tencent_audio(expire_time);

View File

@@ -1,100 +0,0 @@
-- 腾讯广告图片素材表
CREATE SEQUENCE IF NOT EXISTS tencent_image_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS tencent_image (
id BIGINT NOT NULL DEFAULT nextval('tencent_image_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
-- 业务字段
image_id VARCHAR(100) NOT NULL,
account_id BIGINT NOT NULL,
width INT,
height INT,
file_size BIGINT,
type VARCHAR(50),
signature VARCHAR(200),
description TEXT,
source_signature VARCHAR(200),
preview_url TEXT,
thumb_preview_url TEXT,
source_type VARCHAR(100),
image_usage VARCHAR(100),
created_time BIGINT,
last_modified_time BIGINT,
product_catalog_id BIGINT,
product_outer_id VARCHAR(200),
source_reference_id VARCHAR(200),
owner_account_id VARCHAR(100),
status VARCHAR(50),
sample_aspect_ratio VARCHAR(50),
source_material_id VARCHAR(100),
new_source_type VARCHAR(100),
first_publication_status VARCHAR(100),
quality_status VARCHAR(100),
similarity_status VARCHAR(100),
user_aigc_status VARCHAR(100),
system_aigc_status VARCHAR(100),
aigc_source VARCHAR(200),
aigc_flag VARCHAR(50),
muse_aigc_version INT,
aigc_type INT,
-- 本地校验状态
verify_status VARCHAR(20) DEFAULT 'PENDING' NOT NULL, -- PENDING:待校验, VERIFIED:已校验, REJECTED:已拒绝
verified_at TIMESTAMP WITH TIME ZONE, -- 校验时间
verified_by VARCHAR(100), -- 校验人
PRIMARY KEY (id)
);
COMMENT ON TABLE tencent_image IS '腾讯广告图片素材表';
COMMENT ON COLUMN tencent_image.id IS '主键ID';
COMMENT ON COLUMN tencent_image.tenant_id IS '租户ID';
COMMENT ON COLUMN tencent_image.creator IS '创建人';
COMMENT ON COLUMN tencent_image.created_at IS '创建时间';
COMMENT ON COLUMN tencent_image.updater IS '更新人';
COMMENT ON COLUMN tencent_image.updated_at IS '更新时间';
COMMENT ON COLUMN tencent_image.deleted_at IS '软删除时间';
COMMENT ON COLUMN tencent_image.image_id IS '图片ID';
COMMENT ON COLUMN tencent_image.account_id IS '账户ID';
COMMENT ON COLUMN tencent_image.width IS '宽度';
COMMENT ON COLUMN tencent_image.height IS '高度';
COMMENT ON COLUMN tencent_image.file_size IS '文件大小';
COMMENT ON COLUMN tencent_image.type IS '图片类型';
COMMENT ON COLUMN tencent_image.signature IS '签名';
COMMENT ON COLUMN tencent_image.description IS '描述';
COMMENT ON COLUMN tencent_image.source_signature IS '源签名';
COMMENT ON COLUMN tencent_image.preview_url IS '预览URL';
COMMENT ON COLUMN tencent_image.thumb_preview_url IS '缩略图URL';
COMMENT ON COLUMN tencent_image.source_type IS '来源类型';
COMMENT ON COLUMN tencent_image.image_usage IS '图片用途';
COMMENT ON COLUMN tencent_image.created_time IS '创建时间戳';
COMMENT ON COLUMN tencent_image.last_modified_time IS '最后修改时间戳';
COMMENT ON COLUMN tencent_image.product_catalog_id IS '产品目录ID';
COMMENT ON COLUMN tencent_image.product_outer_id IS '产品外部ID';
COMMENT ON COLUMN tencent_image.source_reference_id IS '源引用ID';
COMMENT ON COLUMN tencent_image.owner_account_id IS '所有者账户ID';
COMMENT ON COLUMN tencent_image.status IS '状态';
COMMENT ON COLUMN tencent_image.sample_aspect_ratio IS '示例宽高比';
COMMENT ON COLUMN tencent_image.source_material_id IS '源素材ID';
COMMENT ON COLUMN tencent_image.new_source_type IS '新来源类型';
COMMENT ON COLUMN tencent_image.first_publication_status IS '首次发布状态';
COMMENT ON COLUMN tencent_image.quality_status IS '质量状态';
COMMENT ON COLUMN tencent_image.similarity_status IS '相似度状态';
COMMENT ON COLUMN tencent_image.user_aigc_status IS '用户AIGC状态';
COMMENT ON COLUMN tencent_image.system_aigc_status IS '系统AIGC状态';
COMMENT ON COLUMN tencent_image.aigc_source IS 'AIGC来源';
COMMENT ON COLUMN tencent_image.aigc_flag IS 'AIGC标志';
COMMENT ON COLUMN tencent_image.muse_aigc_version IS 'Muse AIGC版本';
COMMENT ON COLUMN tencent_image.aigc_type IS 'AIGC类型';
-- 唯一索引根据image_id和account_id判断是否存在
CREATE UNIQUE INDEX idx_tencent_image_image_account ON tencent_image(tenant_id, image_id, account_id);
CREATE INDEX idx_tencent_image_account_id ON tencent_image(account_id);
CREATE INDEX idx_tencent_image_last_modified ON tencent_image(last_modified_time);
CREATE INDEX idx_tencent_image_status ON tencent_image(status);

View File

@@ -1,128 +0,0 @@
-- 腾讯广告视频素材表
CREATE SEQUENCE IF NOT EXISTS tencent_video_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS tencent_video (
id BIGINT NOT NULL DEFAULT nextval('tencent_video_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
-- 业务字段
video_id VARCHAR(100) NOT NULL,
account_id BIGINT NOT NULL,
width INT,
height INT,
video_frames INT,
video_fps INT,
video_codec VARCHAR(50),
video_bit_rate BIGINT,
audio_codec VARCHAR(50),
audio_bit_rate BIGINT,
file_size BIGINT,
type VARCHAR(50),
signature VARCHAR(200),
system_status VARCHAR(50),
description TEXT,
preview_url TEXT,
key_frame_image_url TEXT,
created_time BIGINT,
last_modified_time BIGINT,
video_profile_name VARCHAR(50),
audio_sample_rate INT,
max_keyframe_interval INT,
min_keyframe_interval INT,
sample_aspect_ratio VARCHAR(50),
audio_profile_name VARCHAR(50),
scan_type VARCHAR(50),
image_duration_millisecond BIGINT,
audio_duration_millisecond BIGINT,
source_type VARCHAR(100),
product_catalog_id VARCHAR(200),
product_outer_id VARCHAR(200),
source_reference_id VARCHAR(200),
owner_account_id VARCHAR(100),
status VARCHAR(50),
source_material_id VARCHAR(100),
new_source_type VARCHAR(100),
aigc_type INT,
first_publication_status VARCHAR(100),
quality_status VARCHAR(100),
cover_id VARCHAR(100),
similarity_status VARCHAR(100),
user_aigc_status VARCHAR(100),
system_aigc_status VARCHAR(100),
aigc_source VARCHAR(200),
aigc_flag VARCHAR(50),
muse_aigc_version INT,
-- 本地校验状态
verify_status VARCHAR(20) DEFAULT 'PENDING' NOT NULL, -- PENDING:待校验, VERIFIED:已校验, REJECTED:已拒绝
verified_at TIMESTAMP WITH TIME ZONE, -- 校验时间
verified_by VARCHAR(100), -- 校验人
PRIMARY KEY (id)
);
COMMENT ON TABLE tencent_video IS '腾讯广告视频素材表';
COMMENT ON COLUMN tencent_video.id IS '主键ID';
COMMENT ON COLUMN tencent_video.tenant_id IS '租户ID';
COMMENT ON COLUMN tencent_video.creator IS '创建人';
COMMENT ON COLUMN tencent_video.created_at IS '创建时间';
COMMENT ON COLUMN tencent_video.updater IS '更新人';
COMMENT ON COLUMN tencent_video.updated_at IS '更新时间';
COMMENT ON COLUMN tencent_video.deleted_at IS '软删除时间';
COMMENT ON COLUMN tencent_video.video_id IS '视频ID';
COMMENT ON COLUMN tencent_video.account_id IS '账户ID';
COMMENT ON COLUMN tencent_video.width IS '宽度';
COMMENT ON COLUMN tencent_video.height IS '高度';
COMMENT ON COLUMN tencent_video.video_frames IS '视频帧数';
COMMENT ON COLUMN tencent_video.video_fps IS '帧率';
COMMENT ON COLUMN tencent_video.video_codec IS '视频编码';
COMMENT ON COLUMN tencent_video.video_bit_rate IS '视频码率';
COMMENT ON COLUMN tencent_video.audio_codec IS '音频编码';
COMMENT ON COLUMN tencent_video.audio_bit_rate IS '音频码率';
COMMENT ON COLUMN tencent_video.file_size IS '文件大小';
COMMENT ON COLUMN tencent_video.type IS '媒体类型';
COMMENT ON COLUMN tencent_video.signature IS '签名';
COMMENT ON COLUMN tencent_video.system_status IS '系统状态';
COMMENT ON COLUMN tencent_video.description IS '描述';
COMMENT ON COLUMN tencent_video.preview_url IS '预览URL';
COMMENT ON COLUMN tencent_video.key_frame_image_url IS '关键帧图片URL';
COMMENT ON COLUMN tencent_video.created_time IS '创建时间戳';
COMMENT ON COLUMN tencent_video.last_modified_time IS '最后修改时间戳';
COMMENT ON COLUMN tencent_video.video_profile_name IS '视频配置名称';
COMMENT ON COLUMN tencent_video.audio_sample_rate IS '音频采样率';
COMMENT ON COLUMN tencent_video.max_keyframe_interval IS '最大关键帧间隔';
COMMENT ON COLUMN tencent_video.min_keyframe_interval IS '最小关键帧间隔';
COMMENT ON COLUMN tencent_video.sample_aspect_ratio IS '示例宽高比';
COMMENT ON COLUMN tencent_video.audio_profile_name IS '音频配置名称';
COMMENT ON COLUMN tencent_video.scan_type IS '扫描类型';
COMMENT ON COLUMN tencent_video.image_duration_millisecond IS '图片时长(毫秒)';
COMMENT ON COLUMN tencent_video.audio_duration_millisecond IS '音频时长(毫秒)';
COMMENT ON COLUMN tencent_video.source_type IS '来源类型';
COMMENT ON COLUMN tencent_video.product_catalog_id IS '产品目录ID';
COMMENT ON COLUMN tencent_video.product_outer_id IS '产品外部ID';
COMMENT ON COLUMN tencent_video.source_reference_id IS '源引用ID';
COMMENT ON COLUMN tencent_video.owner_account_id IS '所有者账户ID';
COMMENT ON COLUMN tencent_video.status IS '状态';
COMMENT ON COLUMN tencent_video.source_material_id IS '源素材ID';
COMMENT ON COLUMN tencent_video.new_source_type IS '新来源类型';
COMMENT ON COLUMN tencent_video.aigc_type IS 'AIGC类型';
COMMENT ON COLUMN tencent_video.first_publication_status IS '首次发布状态';
COMMENT ON COLUMN tencent_video.quality_status IS '质量状态';
COMMENT ON COLUMN tencent_video.cover_id IS '封面ID';
COMMENT ON COLUMN tencent_video.similarity_status IS '相似度状态';
COMMENT ON COLUMN tencent_video.user_aigc_status IS '用户AIGC状态';
COMMENT ON COLUMN tencent_video.system_aigc_status IS '系统AIGC状态';
COMMENT ON COLUMN tencent_video.aigc_source IS 'AIGC来源';
COMMENT ON COLUMN tencent_video.aigc_flag IS 'AIGC标志';
COMMENT ON COLUMN tencent_video.muse_aigc_version IS 'Muse AIGC版本';
-- 唯一索引根据video_id和account_id判断是否存在
CREATE UNIQUE INDEX idx_tencent_video_video_account ON tencent_video(tenant_id, video_id, account_id);
CREATE INDEX idx_tencent_video_account_id ON tencent_video(account_id);
CREATE INDEX idx_tencent_video_last_modified ON tencent_video(last_modified_time);
CREATE INDEX idx_tencent_video_status ON tencent_video(status);

225
sql/init_core_tables.sql Normal file
View File

@@ -0,0 +1,225 @@
-- =============================================
-- 数据引擎核心表初始化脚本
-- 只需执行此文件即可,其他表由系统自动创建
-- =============================================
-- =============================================
-- 1. 数据源平台配置表 (api_datasource_platform)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS api_datasource_platform_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS api_datasource_platform (
id BIGINT NOT NULL DEFAULT nextval('api_datasource_platform_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
platform_code VARCHAR(100) NOT NULL,
platform_name VARCHAR(200) NOT NULL,
description TEXT,
status VARCHAR(50) DEFAULT 'ACTIVE',
api_base_url VARCHAR(500),
auth_type VARCHAR(50) DEFAULT 'API_KEY',
token VARCHAR(500),
api_key VARCHAR(500),
client_id VARCHAR(200),
client_secret VARCHAR(500),
rate_limit_per_minute INT DEFAULT 60,
rate_limit_per_hour INT DEFAULT 3600,
concurrency_limit INT DEFAULT 10,
request_timeout_ms INT DEFAULT 30000,
max_retries INT DEFAULT 3,
retry_delay_ms INT DEFAULT 1000,
auth_config JSONB,
version INT DEFAULT 0,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_api_datasource_platform_code ON api_datasource_platform(tenant_id, platform_code);
COMMENT ON TABLE api_datasource_platform IS '数据源平台配置表';
COMMENT ON COLUMN api_datasource_platform.id IS '主键ID自增长';
COMMENT ON COLUMN api_datasource_platform.tenant_id IS '租户ID';
COMMENT ON COLUMN api_datasource_platform.creator IS '创建人';
COMMENT ON COLUMN api_datasource_platform.created_at IS '创建时间';
COMMENT ON COLUMN api_datasource_platform.updater IS '更新人';
COMMENT ON COLUMN api_datasource_platform.updated_at IS '更新时间';
COMMENT ON COLUMN api_datasource_platform.deleted_at IS '软删除时间';
COMMENT ON COLUMN api_datasource_platform.platform_code IS '平台编码,唯一标识';
COMMENT ON COLUMN api_datasource_platform.platform_name IS '平台名称';
COMMENT ON COLUMN api_datasource_platform.description IS '平台描述';
COMMENT ON COLUMN api_datasource_platform.status IS '状态: ACTIVE启用, INACTIVE停用';
COMMENT ON COLUMN api_datasource_platform.api_base_url IS 'API基础地址';
COMMENT ON COLUMN api_datasource_platform.auth_type IS '认证类型: TOKEN/API_KEY/OAUTH2/BASIC';
COMMENT ON COLUMN api_datasource_platform.token IS '认证token/密钥(access_token)';
COMMENT ON COLUMN api_datasource_platform.api_key IS 'API Key';
COMMENT ON COLUMN api_datasource_platform.client_id IS 'OAuth2 Client ID';
COMMENT ON COLUMN api_datasource_platform.client_secret IS 'OAuth2 Client Secret';
COMMENT ON COLUMN api_datasource_platform.rate_limit_per_minute IS '每分钟请求限制';
COMMENT ON COLUMN api_datasource_platform.rate_limit_per_hour IS '每小时请求限制';
COMMENT ON COLUMN api_datasource_platform.concurrency_limit IS '并发连接限制';
COMMENT ON COLUMN api_datasource_platform.request_timeout_ms IS '请求超时时间(毫秒)';
COMMENT ON COLUMN api_datasource_platform.max_retries IS '最大重试次数';
COMMENT ON COLUMN api_datasource_platform.retry_delay_ms IS '重试延迟(毫秒)';
COMMENT ON COLUMN api_datasource_platform.auth_config IS '自定义认证配置(JSONB),支持各平台特有的认证方式';
COMMENT ON COLUMN api_datasource_platform.version IS '版本号(乐观锁)';
-- =============================================
-- 2. API接口管理表 (api_interface)
-- =============================================
CREATE SEQUENCE IF NOT EXISTS api_interface_id_seq START WITH 1 INCREMENT BY 1;
CREATE TABLE IF NOT EXISTS api_interface (
id BIGINT NOT NULL DEFAULT nextval('api_interface_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(100) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(100) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
platform_id BIGINT NOT NULL,
name VARCHAR(200) NOT NULL,
code VARCHAR(100) NOT NULL,
url VARCHAR(500) NOT NULL,
method VARCHAR(20) NOT NULL DEFAULT 'GET',
status VARCHAR(50) DEFAULT 'active',
auth_type VARCHAR(50) DEFAULT 'api_key',
request_config JSONB,
response_config JSONB,
limit_config JSONB,
table_definition JSONB,
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_api_interface_code ON api_interface(tenant_id, code);
CREATE INDEX idx_api_interface_platform_id ON api_interface(tenant_id, platform_id);
CREATE INDEX idx_api_interface_status ON api_interface(tenant_id, status);
COMMENT ON TABLE api_interface IS 'API接口管理表';
COMMENT ON COLUMN api_interface.id IS '主键ID自增长';
COMMENT ON COLUMN api_interface.tenant_id IS '租户ID';
COMMENT ON COLUMN api_interface.creator IS '创建人';
COMMENT ON COLUMN api_interface.created_at IS '创建时间';
COMMENT ON COLUMN api_interface.updater IS '更新人';
COMMENT ON COLUMN api_interface.updated_at IS '更新时间';
COMMENT ON COLUMN api_interface.deleted_at IS '软删除时间';
COMMENT ON COLUMN api_interface.platform_id IS '所属平台ID';
COMMENT ON COLUMN api_interface.name IS '接口名称';
COMMENT ON COLUMN api_interface.code IS '接口编码,唯一';
COMMENT ON COLUMN api_interface.url IS '接口地址(相对路径)';
COMMENT ON COLUMN api_interface.method IS '请求方法: GET/POST/PUT/DELETE';
COMMENT ON COLUMN api_interface.status IS '接口状态: active启用/inactive停用';
COMMENT ON COLUMN api_interface.auth_type IS '认证类型: inherit(继承平台)/oauth2/apikey/basic';
COMMENT ON COLUMN api_interface.request_config IS '请求配置(JSONB): 含分页参数、预取配置、时间字段等';
COMMENT ON COLUMN api_interface.response_config IS '响应配置(JSONB): 自定义数据路径等';
COMMENT ON COLUMN api_interface.limit_config IS '接口独立限流配置(JSONB): 可选,覆盖平台配置';
COMMENT ON COLUMN api_interface.table_definition IS '表结构定义(JSONB): 描述目标表的字段结构,用于自动建表';
-- =============================================
-- 3. 同步任务日志表 (sync_task_log)
-- 用于记录同步状态和补偿机制
-- =============================================
CREATE SEQUENCE IF NOT EXISTS sync_task_log_id_seq;
CREATE TABLE IF NOT EXISTS sync_task_log (
id BIGINT NOT NULL DEFAULT nextval('sync_task_log_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
task_id VARCHAR(64) NOT NULL DEFAULT '',
task_type VARCHAR(64) NOT NULL DEFAULT '',
platform_code VARCHAR(100) NOT NULL DEFAULT '',
interface_code VARCHAR(100) NOT NULL DEFAULT '',
advertiser_id BIGINT NOT NULL DEFAULT 0,
start_time TIMESTAMP WITH TIME ZONE,
end_time TIMESTAMP WITH TIME ZONE,
status VARCHAR(32) NOT NULL DEFAULT '',
retry_count INT DEFAULT 0,
max_retry INT DEFAULT 3,
page_info JSONB,
request_params JSONB,
error_message TEXT DEFAULT '',
error_code VARCHAR(64) DEFAULT '',
result_summary JSONB,
next_retry_time TIMESTAMP WITH TIME ZONE,
completed_at TIMESTAMP WITH TIME ZONE,
duration_ms BIGINT DEFAULT 0,
PRIMARY KEY (id)
);
CREATE INDEX idx_sync_task_log_task_id ON sync_task_log(tenant_id, task_id);
CREATE INDEX idx_sync_task_log_platform ON sync_task_log(tenant_id, platform_code);
CREATE INDEX idx_sync_task_log_interface ON sync_task_log(tenant_id, interface_code);
CREATE INDEX idx_sync_task_log_status ON sync_task_log(tenant_id, status);
CREATE INDEX idx_sync_task_log_created_at ON sync_task_log(tenant_id, created_at);
CREATE INDEX idx_sync_task_log_next_retry ON sync_task_log(tenant_id, next_retry_time);
COMMENT ON TABLE sync_task_log IS '同步任务日志表,记录同步状态和补偿信息';
COMMENT ON COLUMN sync_task_log.id IS '主键ID自增长';
COMMENT ON COLUMN sync_task_log.tenant_id IS '租户ID';
COMMENT ON COLUMN sync_task_log.creator IS '创建人';
COMMENT ON COLUMN sync_task_log.created_at IS '创建时间';
COMMENT ON COLUMN sync_task_log.updater IS '更新人';
COMMENT ON COLUMN sync_task_log.updated_at IS '更新时间';
COMMENT ON COLUMN sync_task_log.deleted_at IS '软删除时间';
COMMENT ON COLUMN sync_task_log.task_id IS '任务唯一标识';
COMMENT ON COLUMN sync_task_log.task_type IS '任务类型: full(全量)/incremental(增量)/compensate(补偿)';
COMMENT ON COLUMN sync_task_log.platform_code IS '平台编码';
COMMENT ON COLUMN sync_task_log.interface_code IS '接口编码';
COMMENT ON COLUMN sync_task_log.advertiser_id IS '广告主/账户ID';
COMMENT ON COLUMN sync_task_log.start_time IS '数据开始时间';
COMMENT ON COLUMN sync_task_log.end_time IS '数据结束时间';
COMMENT ON COLUMN sync_task_log.status IS '任务状态: pending/running/success/failed/retrying/manual_review';
COMMENT ON COLUMN sync_task_log.retry_count IS '已重试次数';
COMMENT ON COLUMN sync_task_log.max_retry IS '最大重试次数';
COMMENT ON COLUMN sync_task_log.page_info IS '分页信息快照(JSONB)';
COMMENT ON COLUMN sync_task_log.request_params IS '请求参数快照(JSONB)';
COMMENT ON COLUMN sync_task_log.error_message IS '错误信息';
COMMENT ON COLUMN sync_task_log.error_code IS '错误码';
COMMENT ON COLUMN sync_task_log.result_summary IS '结果摘要(JSONB)';
COMMENT ON COLUMN sync_task_log.next_retry_time IS '下次重试时间';
COMMENT ON COLUMN sync_task_log.completed_at IS '完成时间';
COMMENT ON COLUMN sync_task_log.duration_ms IS '执行耗时(毫秒)';
-- =============================================
-- 4. 同步跟踪表 (sync_tracker)
-- 记录每个平台+接口的最后同步时间,用于增量同步
-- =============================================
CREATE SEQUENCE IF NOT EXISTS sync_tracker_id_seq;
CREATE TABLE IF NOT EXISTS sync_tracker (
id BIGINT NOT NULL DEFAULT nextval('sync_tracker_id_seq'::regclass),
tenant_id BIGINT NOT NULL DEFAULT 0,
creator VARCHAR(64) DEFAULT '',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
updater VARCHAR(64) DEFAULT '',
updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
deleted_at TIMESTAMP WITH TIME ZONE,
platform_code VARCHAR(100) NOT NULL,
interface_code VARCHAR(100) NOT NULL,
last_sync_time BIGINT NOT NULL DEFAULT 0,
last_sync_at TIMESTAMP WITH TIME ZONE,
sync_status VARCHAR(32) DEFAULT 'pending',
PRIMARY KEY (id)
);
CREATE UNIQUE INDEX idx_sync_tracker_unique ON sync_tracker(platform_code, interface_code);
COMMENT ON TABLE sync_tracker IS '同步跟踪表,记录增量同步时间戳';
COMMENT ON COLUMN sync_tracker.id IS '主键ID自增长';
COMMENT ON COLUMN sync_tracker.tenant_id IS '租户ID';
COMMENT ON COLUMN sync_tracker.creator IS '创建人';
COMMENT ON COLUMN sync_tracker.created_at IS '创建时间';
COMMENT ON COLUMN sync_tracker.updater IS '更新人';
COMMENT ON COLUMN sync_tracker.updated_at IS '更新时间';
COMMENT ON COLUMN sync_tracker.deleted_at IS '软删除时间';
COMMENT ON COLUMN sync_tracker.platform_code IS '平台编码';
COMMENT ON COLUMN sync_tracker.interface_code IS '接口编码';
COMMENT ON COLUMN sync_tracker.last_sync_time IS '最后同步时间(Unix时间戳)';
COMMENT ON COLUMN sync_tracker.last_sync_at IS '最后同步时间点';
COMMENT ON COLUMN sync_tracker.sync_status IS '同步状态: pending/success/running/failed';

228
sql/seed_data.sql Normal file
View File

@@ -0,0 +1,228 @@
-- =============================================
-- 数据引擎初始化数据脚本
-- 执行前请先执行 init_core_tables.sql
-- =============================================
-- =============================================
-- 1. 创建腾讯广告平台
-- 认证方式OAuth2access_token 放在 URL 查询参数
-- API Base: https://api.e.qq.com/v3.0
-- =============================================
INSERT INTO api_datasource_platform (
tenant_id, creator, created_at, updater, updated_at,
platform_code, platform_name, description, status,
api_base_url, auth_type,
token, client_id, client_secret,
auth_config,
rate_limit_per_minute, rate_limit_per_hour,
concurrency_limit, request_timeout_ms, max_retries, retry_delay_ms
) VALUES (
1, 'admin', NOW(), 'admin', NOW(),
'tencent', '腾讯广告', '腾讯广告(广点通)数据同步', 'ACTIVE',
'https://api.e.qq.com/v3.0', 'OAUTH2',
'4bacfc7c9b0a31f70ec0eb4771f8b542',
'1112038234', 'GxyjXFbZAs5dnsNQ',
'{
"token_in_query": true,
"query_key": "access_token",
"refresh_token": "d15b37363a42449026d337708516e95e",
"extra_query_params": {
"timestamp": "{timestamp}",
"nonce": "{nonce}"
}
}'::jsonb,
60, 3600, 10, 30000, 3, 1000
);
-- =============================================
-- 2. 创建腾讯广告的接口配置
-- 接口前缀https://api.e.qq.com/v3.0
-- =============================================
-- 2.1 账户关系接口先获取所有账户ID
INSERT INTO api_interface (
tenant_id, creator, created_at, updater, updated_at,
platform_id, name, code, url, method, status, auth_type,
request_config, table_definition
) VALUES (
1, 'admin', NOW(), 'admin', NOW(),
1,
'账户列表', 'account_relation',
'/advertiser/get', 'GET', 'active', 'inherit',
'{
"parameters_location": "query",
"page": 1,
"page_size": 100,
"page_param": "page",
"page_size_param": "page_size",
"pagination_mode": "PAGINATION_MODE_NORMAL",
"fields": ["account_id", "corporation_name", "is_adx", "is_bid", "is_mp"]
}'::jsonb,
'{
"table_name": "tencent_account_relation",
"columns": [
{"name": "account_id", "type": "BIGINT", "comment": "账户ID"},
{"name": "corporation_name", "type": "VARCHAR(300)", "comment": "企业名称"},
{"name": "is_adx", "type": "BOOLEAN", "comment": "是否ADX账户"},
{"name": "is_bid", "type": "BOOLEAN", "comment": "是否竞价账户"},
{"name": "is_mp", "type": "BOOLEAN", "comment": "是否MP账户"}
],
"conflict_keys": ["account_id"]
}'::jsonb
);
-- 2.2 图片素材接口(遍历每个账户拉取图片)
INSERT INTO api_interface (
tenant_id, creator, created_at, updater, updated_at,
platform_id, name, code, url, method, status, auth_type,
request_config, table_definition
) VALUES (
1, 'admin', NOW(), 'admin', NOW(),
1,
'图片素材', 'image',
'/images/get', 'GET', 'active', 'inherit',
'{
"parameters_location": "query",
"page": 1,
"page_size": 100,
"page_param": "page",
"page_size_param": "page_size",
"time_field": "last_modified_time",
"prefetch": {
"url": "/advertiser/get",
"method": "GET",
"response_path": "data.list",
"target_param": "account_id",
"value_field": "account_id"
}
}'::jsonb,
'{
"table_name": "tencent_image",
"columns": [
{"name": "image_id", "type": "VARCHAR(100)", "comment": "图片ID"},
{"name": "account_id", "type": "BIGINT", "comment": "账户ID"},
{"name": "width", "type": "INT", "comment": "宽度"},
{"name": "height", "type": "INT", "comment": "高度"},
{"name": "file_size", "type": "BIGINT", "comment": "文件大小"},
{"name": "type", "type": "VARCHAR(50)", "comment": "图片类型"},
{"name": "signature", "type": "VARCHAR(200)", "comment": "签名"},
{"name": "description", "type": "TEXT", "comment": "描述"},
{"name": "source_signature", "type": "VARCHAR(200)", "comment": "源签名"},
{"name": "preview_url", "type": "TEXT", "comment": "预览URL"},
{"name": "thumb_preview_url", "type": "TEXT", "comment": "缩略图URL"},
{"name": "source_type", "type": "VARCHAR(50)", "comment": "来源类型"},
{"name": "image_usage", "type": "VARCHAR(50)", "comment": "图片用途"},
{"name": "created_time", "type": "BIGINT", "comment": "创建时间戳"},
{"name": "last_modified_time", "type": "BIGINT", "comment": "最后修改时间戳"},
{"name": "status", "type": "VARCHAR(50)", "comment": "状态"},
{"name": "owner_account_id", "type": "VARCHAR(100)", "comment": "所有者账户ID"},
{"name": "first_publication_status", "type": "VARCHAR(50)", "comment": "首次发布状态"},
{"name": "quality_status", "type": "VARCHAR(50)", "comment": "质量状态"},
{"name": "aigc_flag", "type": "VARCHAR(50)", "comment": "AIGC标志"},
{"name": "aigc_type", "type": "INT", "comment": "AIGC类型"},
{"name": "verify_status", "type": "VARCHAR(50) DEFAULT 'PENDING'", "comment": "校验状态"},
{"name": "verified_at", "type": "TIMESTAMP WITH TIME ZONE", "comment": "校验时间"},
{"name": "verified_by", "type": "VARCHAR(64)", "comment": "校验人"}
],
"conflict_keys": ["image_id", "account_id"]
}'::jsonb
);
-- 2.3 视频素材接口(遍历每个账户拉取视频)
INSERT INTO api_interface (
tenant_id, creator, created_at, updater, updated_at,
platform_id, name, code, url, method, status, auth_type,
request_config, table_definition
) VALUES (
1, 'admin', NOW(), 'admin', NOW(),
1,
'视频素材', 'video',
'/videos/get', 'GET', 'active', 'inherit',
'{
"parameters_location": "query",
"page": 1,
"page_size": 100,
"page_param": "page",
"page_size_param": "page_size",
"time_field": "last_modified_time",
"prefetch": {
"url": "/advertiser/get",
"method": "GET",
"response_path": "data.list",
"target_param": "account_id",
"value_field": "account_id"
}
}'::jsonb,
'{
"table_name": "tencent_video",
"columns": [
{"name": "video_id", "type": "BIGINT", "comment": "视频ID"},
{"name": "account_id", "type": "BIGINT", "comment": "账户ID"},
{"name": "width", "type": "INT", "comment": "宽度"},
{"name": "height", "type": "INT", "comment": "高度"},
{"name": "video_frames", "type": "INT", "comment": "视频帧数"},
{"name": "video_fps", "type": "DECIMAL(10,2)", "comment": "视频帧率"},
{"name": "video_codec", "type": "VARCHAR(50)", "comment": "视频编码"},
{"name": "video_bit_rate", "type": "BIGINT", "comment": "视频比特率"},
{"name": "audio_codec", "type": "VARCHAR(50)", "comment": "音频编码"},
{"name": "audio_bit_rate", "type": "BIGINT", "comment": "音频比特率"},
{"name": "file_size", "type": "BIGINT", "comment": "文件大小"},
{"name": "type", "type": "VARCHAR(50)", "comment": "视频类型"},
{"name": "signature", "type": "VARCHAR(200)", "comment": "签名"},
{"name": "system_status", "type": "VARCHAR(50)", "comment": "系统状态"},
{"name": "description", "type": "TEXT", "comment": "描述"},
{"name": "preview_url", "type": "TEXT", "comment": "预览URL"},
{"name": "key_frame_image_url", "type": "TEXT", "comment": "关键帧图片URL"},
{"name": "created_time", "type": "BIGINT", "comment": "创建时间戳"},
{"name": "last_modified_time", "type": "BIGINT", "comment": "最后修改时间戳"},
{"name": "status", "type": "VARCHAR(50)", "comment": "状态"},
{"name": "owner_account_id", "type": "VARCHAR(100)", "comment": "所有者账户ID"},
{"name": "cover_id", "type": "VARCHAR(100)", "comment": "封面ID"},
{"name": "first_publication_status", "type": "VARCHAR(50)", "comment": "首次发布状态"},
{"name": "quality_status", "type": "VARCHAR(50)", "comment": "质量状态"},
{"name": "aigc_flag", "type": "VARCHAR(50)", "comment": "AIGC标志"},
{"name": "muse_aigc_version", "type": "INT", "comment": "Muse AIGC版本"},
{"name": "verify_status", "type": "VARCHAR(50) DEFAULT 'PENDING'", "comment": "校验状态"},
{"name": "verified_at", "type": "TIMESTAMP WITH TIME ZONE", "comment": "校验时间"},
{"name": "verified_by", "type": "VARCHAR(64)", "comment": "校验人"}
],
"conflict_keys": ["video_id", "account_id"]
}'::jsonb
);
-- 2.4 音频素材接口POST + JSON Body无需遍历账户
-- 注意:此接口不依赖 account_id不依赖 prefetch不支持增量
INSERT INTO api_interface (
tenant_id, creator, created_at, updater, updated_at,
platform_id, name, code, url, method, status, auth_type,
request_config, table_definition
) VALUES (
1, 'admin', NOW(), 'admin', NOW(),
1,
'音频素材', 'audio',
'/muse_audios/get', 'POST', 'active', 'inherit',
'{
"page": 1,
"page_size": 100,
"page_param": "page",
"page_size_param": "page_size",
"fields": ["audio_id", "cover_image_url", "audio_name", "author", "duration", "expire_time", "feel_tags", "genre_tags"]
}'::jsonb,
'{
"table_name": "tencent_audio",
"columns": [
{"name": "audio_id", "type": "VARCHAR(100)", "comment": "音乐ID"},
{"name": "audio_name", "type": "VARCHAR(500)", "comment": "音乐名称"},
{"name": "author", "type": "VARCHAR(200)", "comment": "作者"},
{"name": "duration", "type": "DECIMAL(10,2)", "comment": "时长(秒)"},
{"name": "cover_image_url", "type": "TEXT", "comment": "封面图片URL"},
{"name": "expire_time", "type": "BIGINT", "comment": "过期时间戳"},
{"name": "feel_tags", "type": "JSONB", "comment": "情感标签"},
{"name": "genre_tags", "type": "JSONB", "comment": "风格标签"},
{"name": "verify_status", "type": "VARCHAR(50) DEFAULT 'PENDING'", "comment": "校验状态"},
{"name": "verified_at", "type": "TIMESTAMP WITH TIME ZONE", "comment": "校验时间"},
{"name": "verified_by", "type": "VARCHAR(64)", "comment": "校验人"}
],
"conflict_keys": ["audio_id"]
}'::jsonb
);