create table tmp_layer_info (
                                tmp_layer_id         SERIAL               not null,
                                zone_id              INT4                 null,
                                layer_name           VARCHAR(255)         null,
                                create_time          TIMESTAMP            not null default CURRENT_TIMESTAMP,
                                locking              BOOL                 null,
                                user_id              INT4                 null,
                                status               INT2                 not null default 1,
                                layer_id             VARCHAR(255)         null,
                                constraint PK_TMP_LAYER_INFO primary key (tmp_layer_id)
);

comment on table tmp_layer_info is
'临时图层信息';

comment on column tmp_layer_info.tmp_layer_id is
'临时图层ID';

comment on column tmp_layer_info.zone_id is
'作品ID';

comment on column tmp_layer_info.layer_name is
'图层名称';

comment on column tmp_layer_info.create_time is
'创建时间';

comment on column tmp_layer_info.locking is
'是否锁定';

comment on column tmp_layer_info.user_id is
'用户ID';

comment on column tmp_layer_info.status is
'同步状态1:位同步，2：已同步';

comment on column tmp_layer_info.layer_id is
'图层ID';


create table tmp_geom_info (
                               tmp_id               SERIAL               not null,
                               zone_id              INT4                 null,
                               model_id             INT4                 null,
                               layer_id             VARCHAR(255)         null,
                               geom_name            VARCHAR(255)         null,
                               building_id          INT4                 null,
                               floor                INT4                 null,
                               room_id              INT4                 null,
                               geom                 geometry             null,
                               properties           jsonb                null,
                               locking              BOOL                 null,
                               trans                jsonb                null,
                               pics                 varchar(1024)        null,
                               video_url            varchar(1024)        null,
                               audio_url            CHAR(10)             null,
                               brief                text                 null,
                               navigation           BOOL                 null,
                               navigation_end       varchar(100)         null,
                               type_number          INT2                 null,
                               static_id            INT4                 null,
                               material_id          INT4                 null,
                               texture_id           INT4                 null,
                               color                VARCHAR(255)         null,
                               create_time          TIMESTAMP            not null default CURRENT_TIMESTAMP,
                               status               INT2                 not null default 1,
                               user_id              INT4                 null,
                               tmp_layer_id         INT4                 null,
                               constraint PK_TMP_GEOM_INFO primary key (tmp_id)
);

comment on table tmp_geom_info is
'临时空间信息';

comment on column tmp_geom_info.tmp_id is
'临时ID';

comment on column tmp_geom_info.zone_id is
'区域ID';

comment on column tmp_geom_info.model_id is
'模型ID';

comment on column tmp_geom_info.layer_id is
'图层ID';

comment on column tmp_geom_info.geom_name is
'元素名称';

comment on column tmp_geom_info.building_id is
'大楼ID';

comment on column tmp_geom_info.floor is
'楼层';

comment on column tmp_geom_info.room_id is
'房间';

comment on column tmp_geom_info.geom is
'空间信息';

comment on column tmp_geom_info.properties is
'属性信息';

comment on column tmp_geom_info.locking is
'锁定';

comment on column tmp_geom_info.trans is
'变换';

comment on column tmp_geom_info.pics is
'图片地址';

comment on column tmp_geom_info.video_url is
'视频文件地址';

comment on column tmp_geom_info.audio_url is
'音频文件地址';

comment on column tmp_geom_info.brief is
'简介';

comment on column tmp_geom_info.navigation is
'是否导航';

comment on column tmp_geom_info.navigation_end is
'导航终点';

comment on column tmp_geom_info.type_number is
'类型编号0：模型 1：特效';

comment on column tmp_geom_info.static_id is
'特效ID';

comment on column tmp_geom_info.material_id is
'材质ID';

comment on column tmp_geom_info.texture_id is
'贴图ID';

comment on column tmp_geom_info.color is
'颜色';

comment on column tmp_geom_info.create_time is
'创建时间';

comment on column tmp_geom_info.status is
'同步状态1:位同步，2：已同步';

comment on column tmp_geom_info.user_id is
'用户ID';

comment on column tmp_geom_info.tmp_layer_id is
'临时图层ID';

alter table tmp_geom_info
    add constraint FK_TMP_GEOM_REF_LAYER foreign key (tmp_layer_id)
        references tmp_layer_info (tmp_layer_id)
        on delete cascade on update cascade;
