/**Begin D:\PDM_UPGRADE\PDM1\FA_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_DATA_ASSET')
CREATE TABLE T_FA_DATA_ASSET (
                                 FID BIGINT DEFAULT 0 NOT NULL,
                                 FACCOUNTORGID BIGINT DEFAULT 0 NOT NULL,
                                 FORGID BIGINT DEFAULT 0 NOT NULL,
                                 FREGISTDATE DATETIME DEFAULT GETDATE() NOT NULL,
                                 FBILLNO VARCHAR(255) DEFAULT ' ' NOT NULL,
                                 FCONTENT VARCHAR(255) DEFAULT ' ' NOT NULL,
                                 FBILLSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                 FREMARK VARCHAR(500) DEFAULT ' ' NOT NULL,
                                 FASSETNAME VARCHAR(300) DEFAULT ' ' NOT NULL,
                                 FMODEL VARCHAR(255) DEFAULT ' ' NOT NULL,
                                 FSTOREPLACEID BIGINT DEFAULT 0 NOT NULL,
                                 FQTYUNITID BIGINT DEFAULT 0 NOT NULL,
                                 FASSETQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                 FSCALEUNITID BIGINT DEFAULT 0 NOT NULL,
                                 FSCALEQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                 FSOURCETYPEID BIGINT DEFAULT 0 NOT NULL,
                                 FFREQUENCY VARCHAR(2) DEFAULT ' ' NOT NULL,
                                 FKEEPDEPTID BIGINT DEFAULT 0 NOT NULL,
                                 FKEEPERID BIGINT DEFAULT 0 NOT NULL,
                                 FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
                                 FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                 FCREATETIME DATETIME,
                                 FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                 FMODIFYTIME DATETIME,
                                 FAUDITORID BIGINT DEFAULT 0 NOT NULL,
                                 FAUDITDATE DATETIME,
                                 FBIZSTATUS VARCHAR(50) DEFAULT 'READY' NOT NULL,
                                 FINITQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                 FLASTMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_DATA_ASSET_L')
CREATE TABLE T_FA_DATA_ASSET_L (
                                   FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
                                   FID BIGINT DEFAULT 0 NOT NULL,
                                   FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
                                   FASSETNAME NVARCHAR(300) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FA_DATA_DETAIL')
CREATE TABLE T_FA_DATA_DETAIL (
                                  FID BIGINT DEFAULT 0 NOT NULL,
                                  FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                  FSEQ INT DEFAULT 0 NOT NULL,
                                  FNAME VARCHAR(300) DEFAULT ' ' NOT NULL,
                                  FDETAILQTY DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                  FUNITID BIGINT DEFAULT 0 NOT NULL,
                                  FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
                                  FSTATUS CHAR(1) DEFAULT '1' NOT NULL,
                                  FREMARK VARCHAR(500) DEFAULT ' ' NOT NULL,
                                  FDETAILMODIFER BIGINT DEFAULT 0 NOT NULL,
                                  FMODIFYTIME DATETIME DEFAULT GETDATE() NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FA_ASSETCATEGORY' AND KSQL_COL_NAME IN ('FAPPLYTYPE'))
ALTER TABLE T_FA_ASSETCATEGORY ADD (FAPPLYTYPE VARCHAR(2) DEFAULT ' ' NOT NULL );
/**End D:\PDM_UPGRADE\PDM1\FA_table.sql **/