Files
workspace/code/app/app-go/db/clothing.sql
T
2026-06-30 22:46:53 +08:00

137 lines
3.9 KiB
SQL

drop table if exists b_clothing_tag_relation;
drop table if exists b_clothing_outfit_clothes;
drop table if exists b_clothing_tag;
drop table if exists b_clothing_tag_group;
drop table if exists b_clothing_category;
drop table if exists b_clothing_outfit;
drop table if exists b_clothing_clothes;
create table b_clothing_clothes (
id bigint primary key,
family_id bigint not null,
name varchar(64) not null,
image_file_key varchar(512) not null,
category_id bigint,
brand varchar(64) default '',
remark varchar(512) default '',
sort_number int not null default 0,
status smallint not null default 1,
create_time timestamp,
update_time timestamp,
create_by bigint,
update_by bigint
);
create table b_clothing_outfit (
id bigint primary key,
family_id bigint not null,
name varchar(64) not null,
cover_file_key varchar(512) default '',
layout_json jsonb,
category_id bigint,
remark varchar(512) default '',
sort_number int not null default 0,
status smallint not null default 1,
create_time timestamp,
update_time timestamp,
create_by bigint,
update_by bigint
);
create table b_clothing_outfit_clothes (
id bigint primary key,
family_id bigint not null,
outfit_id bigint not null,
clothes_id bigint not null,
x numeric(8, 6) not null default 0,
y numeric(8, 6) not null default 0,
width numeric(8, 6) not null default 0,
height numeric(8, 6) not null default 0,
z_index int not null default 0,
sort_number int not null default 0,
create_time timestamp,
update_time timestamp,
create_by bigint,
update_by bigint
);
create table b_clothing_category (
id bigint primary key,
family_id bigint not null,
name varchar(32) not null,
type smallint not null,
sort_number int not null default 0,
status smallint not null default 1,
create_time timestamp,
update_time timestamp,
create_by bigint,
update_by bigint
);
create table b_clothing_tag_group (
id bigint primary key,
family_id bigint not null,
name varchar(32) not null,
type smallint not null,
sort_number int not null default 0,
status smallint not null default 1,
create_time timestamp,
update_time timestamp,
create_by bigint,
update_by bigint
);
create table b_clothing_tag (
id bigint primary key,
family_id bigint not null,
tag_group_id bigint not null,
name varchar(32) not null,
type smallint not null,
color varchar(7) default '',
sort_number int not null default 0,
status smallint not null default 1,
create_time timestamp,
update_time timestamp,
create_by bigint,
update_by bigint
);
create table b_clothing_tag_relation (
id bigint primary key,
family_id bigint not null,
target_type smallint not null,
target_id bigint not null,
tag_id bigint not null,
create_time timestamp,
update_time timestamp,
create_by bigint,
update_by bigint
);
create index idx_b_clothing_clothes_family_status_category
on b_clothing_clothes (family_id, status, category_id, sort_number, id);
create index idx_b_clothing_outfit_family_status_category
on b_clothing_outfit (family_id, status, category_id, sort_number, id);
create index idx_b_clothing_outfit_clothes_outfit
on b_clothing_outfit_clothes (outfit_id, z_index, sort_number, id);
create index idx_b_clothing_outfit_clothes_clothes
on b_clothing_outfit_clothes (family_id, clothes_id, outfit_id);
create index idx_b_clothing_category_family_type
on b_clothing_category (family_id, status, type, sort_number, id);
create index idx_b_clothing_tag_group_family_type
on b_clothing_tag_group (family_id, status, type, sort_number, id);
create index idx_b_clothing_tag_family_group
on b_clothing_tag (family_id, status, type, tag_group_id, sort_number, id);
create index idx_b_clothing_tag_relation_target
on b_clothing_tag_relation (family_id, target_type, target_id, tag_id);
create index idx_b_clothing_tag_relation_tag
on b_clothing_tag_relation (family_id, tag_id, target_type, target_id);