-- Studio 项目空间表。

CREATE TABLE IF NOT EXISTS studio_project (
    id BIGSERIAL PRIMARY KEY,
    project_code VARCHAR(100) NOT NULL,
    project_name VARCHAR(200) NOT NULL,
    environment VARCHAR(50) NOT NULL DEFAULT 'DEV',
    publish_status VARCHAR(50) NOT NULL DEFAULT 'DRAFT',
    current_version VARCHAR(50),
    version INTEGER NOT NULL DEFAULT 1,
    create_time TIMESTAMP,
    update_time TIMESTAMP,
    remark VARCHAR(500) DEFAULT '',
    create_by VARCHAR(64),
    update_by VARCHAR(64),
    CONSTRAINT uk_studio_project_code UNIQUE (project_code)
);

CREATE INDEX IF NOT EXISTS idx_studio_project_environment ON studio_project (environment);
CREATE INDEX IF NOT EXISTS idx_studio_project_publish_status ON studio_project (publish_status);

COMMENT ON TABLE studio_project IS 'Studio项目空间表';
COMMENT ON COLUMN studio_project.id IS 'ID';
COMMENT ON COLUMN studio_project.project_code IS '项目编码';
COMMENT ON COLUMN studio_project.project_name IS '项目名称';
COMMENT ON COLUMN studio_project.environment IS '环境';
COMMENT ON COLUMN studio_project.publish_status IS '发布状态';
COMMENT ON COLUMN studio_project.current_version IS '当前发布版本';
COMMENT ON COLUMN studio_project.version IS '版本';
COMMENT ON COLUMN studio_project.create_time IS '创建时间';
COMMENT ON COLUMN studio_project.update_time IS '更新时间';
COMMENT ON COLUMN studio_project.remark IS '备注';
COMMENT ON COLUMN studio_project.create_by IS '创建者';
COMMENT ON COLUMN studio_project.update_by IS '更新者';
