/**Begin D:\PDM_UPGRADE\PDM1\HAOS_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_OTCLASSIFY' AND KSQL_COL_NAME IN ('FISSTANDARTPERM'))
 ALTER TABLE T_HAOS_OTCLASSIFY ADD (FISSTANDARTPERM CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAM' AND KSQL_COL_NAME IN ('FISVIRTUALORG'))
 ALTER TABLE T_HAOS_ORGTEAM ADD (FISVIRTUALORG CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ORGTEAMSTRUCT' AND KSQL_COL_NAME IN ('FSTRUCTPROJECTID'))
 ALTER TABLE T_HAOS_ORGTEAMSTRUCT ADD (FSTRUCTPROJECTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINSTRUCT' AND KSQL_COL_NAME IN ('FSTRUCTPROJECTID'))
 ALTER TABLE T_HAOS_ADMINSTRUCT ADD (FSTRUCTPROJECTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HAOS_ADMINORG' AND KSQL_COL_NAME IN ('FISVIRTUALORG'))
 ALTER TABLE T_HAOS_ADMINORG ADD (FISVIRTUALORG CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_STRUCTPROJECT')
 CREATE TABLE T_HAOS_STRUCTPROJECT (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FSTATUS VARCHAR(2) DEFAULT 'C' NOT NULL,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
FINDEX INT DEFAULT 0 NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FOTCLASSIFYID BIGINT DEFAULT 0 NOT NULL,
FISINCLUDEVIRTUALORG CHAR(1) DEFAULT '0' NOT NULL,
FISCUSTOMORG CHAR(1) DEFAULT '0' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FRELYONSTRUCTPROJECTID BIGINT DEFAULT 0 NOT NULL,
FROOTORGID BIGINT DEFAULT 0 NOT NULL,
FROOTTYPE VARCHAR(2) DEFAULT '1' NOT NULL,
FROOTNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FROOTNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FROOTEFFDT DATETIME,
FROOTDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_STRUCTPROJECT_L')
 CREATE TABLE T_HAOS_STRUCTPROJECT_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FROOTNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FROOTDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_STRUCTPROCONFIG')
 CREATE TABLE T_HAOS_STRUCTPROCONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FENTITYTYPEID VARCHAR(60) DEFAULT ' ' NOT NULL ,
FAPPID VARCHAR(32) DEFAULT ' ' NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_STRPROFIELDENTRY')
 CREATE TABLE T_HAOS_STRPROFIELDENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FTEAMTYPEID BIGINT DEFAULT 0 NOT NULL,
FCOLUMNNAME VARCHAR(60) DEFAULT ' ' NOT NULL,
FCOLUMN VARCHAR(60) DEFAULT ' ' NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_STRCONOTCLASSIFY')
 CREATE TABLE T_HAOS_STRCONOTCLASSIFY (
FPKID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_STRPROJECTENTRY')
 CREATE TABLE T_HAOS_STRPROJECTENTRY (
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSTRUCTPROJECTID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HAOS_STRPROFIELDENTRY_L')
 CREATE TABLE T_HAOS_STRPROFIELDENTRY_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);



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