/**Begin C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_BLUEPRINT_SHARE')
CREATE TABLE T_PUR_BLUEPRINT_SHARE (
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FORGID BIGINT DEFAULT 0 NOT NULL,
                                       FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                       FSOURCEDATAID BIGINT DEFAULT 0 NOT NULL,
                                       FBITINDEX INT DEFAULT 0 NOT NULL,
                                       FSOURCEBITINDEX INT DEFAULT 0 NOT NULL,
                                       FSRCCREATEORGID BIGINT DEFAULT 0 NOT NULL,
                                       FICON NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                       FMATERIELID BIGINT DEFAULT 0 NOT NULL,
                                       FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                       FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                       FVERSION NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                       FSORT NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                       FGROUPID BIGINT DEFAULT 0 NOT NULL,
                                       FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
                                       FCTRLSTRATEGY CHAR(1) DEFAULT ' ' NOT NULL,
                                       FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
                                       FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                       FSOURCETYPE CHAR(1) DEFAULT ' ' NOT NULL,
                                       FISLATESTVERSION CHAR(1) DEFAULT '0' NOT NULL,
                                       FDOCUMENTIDS NVARCHAR(512) DEFAULT ' ' NOT NULL,
                                       FDOCUMENTNAME NVARCHAR(512) DEFAULT ' ' NOT NULL,
                                       FUSEORGID BIGINT DEFAULT 0 NOT NULL,
                                       FNOTES NVARCHAR(512) DEFAULT ' ' NOT NULL,
                                       FFILELINK NVARCHAR(512) DEFAULT ' ' NOT NULL,
                                       FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                       FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                       FAUDITORID BIGINT DEFAULT 0 NOT NULL,
                                       FCREATETIME DATETIME,
                                       FMODIFYTIME DATETIME,
                                       FAUDITDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_BULEPRINTENTRY')
CREATE TABLE T_PUR_BULEPRINTENTRY (
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                      FSEQ INT DEFAULT 0 NOT NULL,
                                      FSUPPLIERID BIGINT DEFAULT 0 NOT NULL,
                                      FCONTACTID BIGINT DEFAULT 0 NOT NULL,
                                      FPHONENUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                      FBIZPARTNERID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_BLUEPRINT_SHARE_L')
CREATE TABLE T_PUR_BLUEPRINT_SHARE_L (
                                         FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
                                         FID BIGINT DEFAULT 0 NOT NULL,
                                         FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
                                         FREMARK NVARCHAR(512) DEFAULT ' ' NOT NULL,
                                         FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_BLUEPRINTGROUP')
CREATE TABLE T_PUR_BLUEPRINTGROUP (
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FNUMBER NVARCHAR(80) DEFAULT ' ' NOT NULL,
                                      FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                      FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                      FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                      FDISABLERID BIGINT DEFAULT 0 NOT NULL,
                                      FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                      FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
                                      FLEVEL INT DEFAULT 0 NOT NULL,
                                      FLONGNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                      FFULLNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                      FISLEAF CHAR(1) DEFAULT '1' NOT NULL,
                                      FPARENTID BIGINT DEFAULT 0 NOT NULL,
                                      FCREATETIME DATETIME,
                                      FDISABLEDATE DATETIME,
                                      FMODIFYTIME DATETIME,
                                      FMASTERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_PUR_BLUEPRINTGROUP_L')
CREATE TABLE T_PUR_BLUEPRINTGROUP_L (
                                        FPKID NVARCHAR(36) DEFAULT ' ' NOT NULL,
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
                                        FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                        FFULLNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);

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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_PUR_BLUEPRINTGROUP' AND KSQL_COL_NAME IN ('FISLEAF'))
ALTER TABLE T_PUR_BLUEPRINTGROUP ADD (FISLEAF CHAR(1) DEFAULT '1' NOT NULL );
 --- drop column --------- 请认真检查该脚本 -------------------
EXEC p_AlterColumn 'T_PUR_BLUEPRINTGROUP', 'FENABLE2', 'NULL', 'NULL', '1001', 'NULL';

/**End C:\PDM_UPGRADE\PDM1\PUR_table.sql **/
