chenhj
7 天以前 aa2b64bd7fd77b065b08fee39521d772c0b39fa4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
-- ----------------------------
-- 附件表
-- ----------------------------
drop table if exists storage_attachment;
CREATE TABLE storage_attachments
(
    id              bigserial PRIMARY KEY,
    created_at      timestamp    default now() NOT NULL,
    updated_at      timestamp    default now() NOT NULL,
    deleted_at      bigint       DEFAULT 0     NOT NULL,
    record_type     smallint     DEFAULT 0     NOT NULL,
    record_id       bigint       DEFAULT 0     NOT NULL,
    name            varchar(100) DEFAULT ''    NOT NULL,
    storage_blob_id bigint       DEFAULT 0     NOT NULL
);
 
COMMENT ON TABLE storage_attachments IS '通用文件上传的附件信息';
 
COMMENT ON COLUMN storage_attachments.record_type IS '关联的记录类型';
COMMENT ON COLUMN storage_attachments.record_id IS '关联的记录id';
COMMENT ON COLUMN storage_attachments.name IS '名称, 如: file, avatar (区分同一条记录不同类型的附件)';
COMMENT ON COLUMN storage_attachments.storage_blob_id IS '关联storage_blob记录id';
 
CREATE INDEX idx_storage_attachments_on_record
    ON storage_attachments (record_type, record_id);