-- =============================================
-- SEAL_CONTRACT_LAUNCH_PLAN 建表脚本 (Oracle)
-- 自动整理生成，已合并历史patch字段
-- 执行方式: sqlplus developer/dev123@localhost/XEPDB1 @SEAL_CONTRACT_LAUNCH_PLAN.sql
-- =============================================

WHENEVER SQLERROR EXIT SQL.SQLCODE;

BEGIN
    EXECUTE IMMEDIATE 'DROP SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_PLAN';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -2289 THEN RAISE; END IF;
END;
/

BEGIN
    EXECUTE IMMEDIATE 'DROP TABLE SEAL_CONTRACT_LAUNCH_PLAN CASCADE CONSTRAINTS';
EXCEPTION
    WHEN OTHERS THEN
        IF SQLCODE != -942 THEN RAISE; END IF;
END;
/

CREATE TABLE SEAL_CONTRACT_LAUNCH_PLAN (
    ID NUMBER(19) NOT NULL,
    CONTRACT_ID NUMBER(19) NOT NULL,
    PLAN_MATTER VARCHAR2(500 CHAR) NOT NULL,
    PLAN_WHERE VARCHAR2(500 CHAR) NOT NULL,
    PLAN_TIME DATE NOT NULL,
    PLAN_DAY NUMBER(10) DEFAULT 3,
    PLAN_MONEY NUMBER(20, 2),
    PLAN_SUBJECT_CODE VARCHAR2(100 CHAR),
    PLAN_SUBJECT_NAME VARCHAR2(200 CHAR),
    EXECUTOR_UNIT_ID NUMBER(19),
    PLAN_DETAIL VARCHAR2(1000 CHAR),
    PLAN_STATUS VARCHAR2(20 CHAR) DEFAULT '0',
    CREATE_BY VARCHAR2(64 CHAR),
    CREATE_TIME DATE DEFAULT SYSDATE,
    UPDATE_BY VARCHAR2(64 CHAR),
    UPDATE_TIME DATE DEFAULT SYSDATE,
    IS_DELETED VARCHAR2(2 CHAR) DEFAULT 'N',
    REMARK VARCHAR2(1000 CHAR),
    CONSTRAINT PK_SEAL_CONTRACT_LAUNCH_PLAN PRIMARY KEY (ID)
);

COMMENT ON TABLE SEAL_CONTRACT_LAUNCH_PLAN IS '合同履行计划表';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.ID IS '主键ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.CONTRACT_ID IS '合同主表ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_MATTER IS '履行事项';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_WHERE IS '履约条件';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_TIME IS '节点日期';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_DAY IS '提前提醒天数';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_MONEY IS '款项金额';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_SUBJECT_CODE IS '所属主体编码';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_SUBJECT_NAME IS '所属主体名称';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.EXECUTOR_UNIT_ID IS '执行人公司ID';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_DETAIL IS '备注';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.PLAN_STATUS IS '反馈状态';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.CREATE_BY IS '创建人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.CREATE_TIME IS '创建时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.UPDATE_BY IS '更新人';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.UPDATE_TIME IS '更新时间';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.IS_DELETED IS '逻辑删除标记';
COMMENT ON COLUMN SEAL_CONTRACT_LAUNCH_PLAN.REMARK IS '备注';

CREATE INDEX IDX_SC_PLAN_CTID ON SEAL_CONTRACT_LAUNCH_PLAN (CONTRACT_ID);

CREATE SEQUENCE SEQ_SEAL_CONTRACT_LAUNCH_PLAN
    INCREMENT BY 1
    MINVALUE 1
    MAXVALUE 9999999999999999999999999999
    NOCYCLE
    CACHE 20
    NOORDER;

COMMIT;
