/**Begin D:\PDM_UPGRADE\PDM1\EB_constraint.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPLYTEMPLATE_ATCFG') 
CREATE TABLE T_EB_APPLYTEMPLATE_ATCFG
(
    FID                 BIGINT                                     NOT NULL,
    FENTRYID            BIGINT                                     NOT NULL,
    FSEQ                INTEGER     DEFAULT 0                      NOT NULL,
    FAUDITTRAILMEMBERID BIGINT,
    FAUDITTRAILUSE      VARCHAR(50) DEFAULT ' '  NOT NULL,
    FAUDITTRAILMEMNUM   VARCHAR(50) DEFAULT ' '  NOT NULL
);

EXEC P_ALTERPK 'PK_EB_APPLYTEMPLATE_ATCFG', 'T_EB_APPLYTEMPLATE_ATCFG', 'FENTRYID', '1';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPLYTEMPLATE_COLCFG') 
CREATE TABLE T_EB_APPLYTEMPLATE_COLCFG
(
    FID                  BIGINT                                     NOT NULL,
    FAPPLYTEMPLATEID     BIGINT,
    FAPPLYTEMPLATENUMBER VARCHAR(50) DEFAULT ' '  NOT NULL,
    FCREATOR             BIGINT,
    FMODIFIER            BIGINT,
    FFORMTYPE            VARCHAR(50) DEFAULT ' ' NOT NULL,
    FEDITTYPE            VARCHAR(50) DEFAULT ' ' NOT NULL,
    FCOLKEY              VARCHAR(50) DEFAULT ' ' NOT NULL,
    FAUDITTRAILMEMID     BIGINT,
    FAUDITTRAILMEMNUM    VARCHAR(50) DEFAULT ' ' NOT NULL,
    FMODIFYDATE          TIMESTAMP,
    FCREATEDATE          TIMESTAMP,
    FAGGREGATE           VARCHAR(50) DEFAULT ' ' NOT NULL
);
EXEC P_ALTERPK 'PK_EB_APPLYTEMPLATE_COLCFG', 'T_EB_APPLYTEMPLATE_COLCFG', 'FID', '1';


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPLYTEMPLATE_DIMCFG') 
CREATE TABLE T_EB_APPLYTEMPLATE_DIMCFG
(
    FID                  BIGINT                                     NOT NULL,
    FCREATOR             BIGINT,
    FAPPLYTEMPLATEID     BIGINT,
    FAPPLYTEMPLATENUMBER VARCHAR(50) DEFAULT ' '  NOT NULL,
    FTABLECFGID          BIGINT,
    FUSETYPE             VARCHAR(50) DEFAULT ' '  NOT NULL,
    FDIMNUM              VARCHAR(50) DEFAULT ' '  NOT NULL,
    FDIMID               BIGINT,
    FMODIFYDATE          TIMESTAMP,
    FCREATEDATE          TIMESTAMP,
    FMODIFIER            BIGINT
);
EXEC P_ALTERPK 'PK_EB_APPLYTEMPLATE_DIMCFG', 'T_EB_APPLYTEMPLATE_DIMCFG', 'FID', '1';


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPLYTEMPLATE_TBCFG') 
CREATE TABLE T_EB_APPLYTEMPLATE_TBCFG
(
    FID                  BIGINT                                       NOT NULL,
    FCREATOR             BIGINT,
    FMODIFIER            BIGINT,
    FAPPLYTEMPLATEID     BIGINT,
    FAPPLYTEMPLATENUMBER VARCHAR(50)   DEFAULT ' '  NOT NULL,
    FTABLENAME           VARCHAR(50)   DEFAULT ' '  NOT NULL,
    FCREATEDATE          TIMESTAMP,
    FMODIFYDATE          TIMESTAMP,
    FCOLUMNJSON          VARCHAR(2000) DEFAULT ' '  NOT NULL
);
EXEC P_ALTERPK 'PK_EB_APPLYTEMPLATE_TBCFG', 'T_EB_APPLYTEMPLATE_TBCFG', 'FID', '1';

/**End D:\PDM_UPGRADE\PDM1\EB_constraint.sql **/