-- ---------------------------- -- 附件表 -- ---------------------------- 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);