/**Begin D:\PDM\pdm_upgrade\pdm1\ER_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_TRIP_ENUM')
CREATE TABLE T_ER_TRIP_ENUM (
                                FID BIGINT DEFAULT 0 NOT NULL,
                                FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
                                FNAME VARCHAR(30) DEFAULT ' ' NOT NULL,
                                FSTATUS VARCHAR(10) DEFAULT ' ' NOT NULL,
                                FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                FENABLE VARCHAR(10) DEFAULT ' ' NOT NULL,
                                FCREATETIME DATETIME,
                                FMODIFYTIME DATETIME,
                                FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                FSERVER BIGINT DEFAULT 0 NOT NULL,
                                FFUNCTION VARCHAR(50) DEFAULT ' ' NOT NULL,
                                FBILLFIELD VARCHAR(255) DEFAULT ' ' NOT NULL,
                                FBILLVALUE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                FJSONFIELD VARCHAR(255) DEFAULT ' ' NOT NULL,
                                FJSONVALUE VARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_TRIP_ENUM_L')
CREATE TABLE T_ER_TRIP_ENUM_L (
                                  FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
                                  FID BIGINT DEFAULT 0 NOT NULL,
                                  FLOCALEID VARCHAR(50) DEFAULT ' ' NOT NULL,
                                  FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);



/**End D:\PDM\pdm_upgrade\pdm1\ER_table.sql **/


/**Begin D:\PDM\pdm_upgrade\pdm1\ER_constraint.sql **/
EXEC P_ALTERPK 'PK_T_ER_TRIP_ENUM', 'T_ER_TRIP_ENUM', 'FID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'UQ_ENUMSERVERJSONFIELD') CREATE UNIQUE  CLUSTERED INDEX UQ_ENUMSERVERJSONFIELD ON T_ER_TRIP_ENUM ( FSERVER ,FFUNCTION ,FJSONFIELD );


EXEC P_ALTERPK 'PK_T_ER_TRIP_ENUM_L', 'T_ER_TRIP_ENUM_L', 'FPKID', '0';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_TRIP_ENUMFID') CREATE  CLUSTERED INDEX IDX_TRIP_ENUMFID ON T_ER_TRIP_ENUM_L ( FID );



/**End D:\PDM\pdm_upgrade\pdm1\ER_constraint.sql **/
