-- auto-generated definition
create table tencent_ads_auth
(
    id                       bigint auto_increment comment '主键ID'
        primary key,
    account_id               varchar(64)                          not null comment '账户ID（腾讯广告账户ID）',
    account_uin              bigint                               null comment '账户UIN',
    scope_list               text                                 null comment '授权范围列表（JSON格式）',
    wechat_account_id        varchar(128)                         null comment '微信账户ID',
    account_role_type        varchar(64)                          null comment '账户角色类型',
    account_type             varchar(64)                          null comment '账户类型',
    role_type                varchar(64)                          null comment '角色类型',
    access_token             varchar(512)                         not null comment '访问令牌',
    refresh_token            varchar(512)                         not null comment '刷新令牌',
    access_token_expires_at  datetime                             not null comment '访问令牌过期时间',
    refresh_token_expires_at datetime                             not null comment '刷新令牌过期时间',
    scope                    varchar(512)                         null comment '授权范围',
    status                   tinyint(1) default 1                 not null comment '状态：0-失效，1-有效',
    create_time              datetime   default CURRENT_TIMESTAMP not null comment '创建时间',
    update_time              datetime   default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '更新时间',
    deleted                  tinyint(1) default 0                 not null comment '逻辑删除标识：0-未删除，1-已删除',
    constraint uidx_account_id
        unique (account_id)
)
    comment '腾讯广告OAuth授权表';

create index idx_access_token_expires_at
    on tencent_ads_auth (access_token_expires_at);

create index idx_create_time
    on tencent_ads_auth (create_time);

create index idx_status
    on tencent_ads_auth (status);

-- 腾讯广告组表
create table tencent_ads_adgroup
(
    id                  bigint auto_increment comment '主键ID'
        primary key,
    account_id          bigint                          not null comment '账户ID',
    adgroup_id          bigint                               not null comment '广告组ID',
    adgroup_name        varchar(256)                         null comment '广告组名称',
    configured_status   varchar(32)                          null comment '配置状态',
    daily_budget        bigint                               null comment '日预算（单位：分）',
    created_time        bigint                               null comment '创建时间（时间戳）',
    marketing_scene     varchar(64)                          null comment '营销场景',
    last_modified_time  bigint                               null comment '最后修改时间（时间戳）',
    is_deleted          tinyint(1) default 0                 null comment '是否已删除：0-否，1-是',
    marketing_goal      varchar(64)                          null comment '营销目标',
    marketing_asset_outer_spec varchar(64)                   null comment '营销资产外层规格',
    marketing_target_type varchar(64)                        null comment '营销目标类型',
    marketing_asset_outer_id varchar(128)                    null comment '营销资产外层ID',
    marketing_asset_outer_name varchar(256)                  null comment '营销资产外层名称',
    marketing_carrier_type varchar(64)                       null comment '营销载体类型',
    optimization_goal   varchar(64)                          null comment '优化目标',
    conversion_id       varchar(128)                         null comment '转化ID',
    site_set            text                                 null comment '投放站点集合',
    targeting           text                                 null comment '定向设置',
    bid_mode            varchar(64)                          null comment '出价模式',
    bid_scene           varchar(64)                          null comment '出价场景',
    begin_date          varchar(32)                          null comment '开始日期',
    end_date            varchar(32)                          null comment '结束日期',
    time_series         text                                 null comment '时间序列',
    auto_derived_creative_enabled varchar(16)                null comment '是否启用自动衍生创意',
    creative_components text                                 null comment '创意组件',
    create_time         datetime   default CURRENT_TIMESTAMP not null comment '记录创建时间',
    update_time         datetime   default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment '记录更新时间',
    constraint uidx_account_adgroup
        unique (account_id, adgroup_id)
)
    comment '腾讯广告组表';

create index idx_last_modified_time
    on tencent_ads_adgroup (last_modified_time);

create index idx_configured_status
    on tencent_ads_adgroup (configured_status);

