/**Begin 立项单主键及索引 **/

/**立项单关联子实体 **/
 EXEC P_ALTERPK 'PK_ER_APPLYPROJECTBILL_LK', 'T_ER_APPLYPROJECTBILL_LK', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECT_LK_FID') CREATE INDEX IDX_ER_APPLYPROJECT_LK_FID ON T_ER_APPLYPROJECTBILL_LK ( FID );

/**立项单反写记录 **/
 EXEC P_ALTERPK 'PK_ER_APPLYPROJECTBILL_WB', 'T_ER_APPLYPROJECTBILL_WB', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECT_WB_FID') CREATE INDEX IDX_ER_APPLYPROJECT_WB_FID ON T_ER_APPLYPROJECTBILL_WB ( FID );

/**立项单追踪 **/
 EXEC P_ALTERPK 'PK_ER_APPLYPROJECTBILL_TC', 'T_ER_APPLYPROJECTBILL_TC', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECT_TC_FTBLD') CREATE INDEX IDX_ER_APPLYPROJECT_TC_FTBLD ON T_ER_APPLYPROJECTBILL_TC ( FTBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECT_TC_FSBLD') CREATE INDEX IDX_ER_APPLYPROJECT_TC_FSBLD ON T_ER_APPLYPROJECTBILL_TC ( FSBILLID );

/**立项单分录关联 **/
 EXEC P_ALTERPK 'PK_ER_APPLYPROJECTENTRY_LK', 'T_ER_APPLYPROJECTENTRY_LK', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECTET_LK_FETID') CREATE INDEX IDX_ER_APPLYPROJECTET_LK_FETID ON T_ER_APPLYPROJECTENTRY_LK ( FENTRYID );

/**立项单项目干系人 **/
 EXEC P_ALTERPK 'PK_ER_APPLYPROJECTOWER', 'T_ER_APPLYPROJECTOWER', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECTOWER_FID') CREATE INDEX IDX_ER_APPLYPROJECTOWER_FID ON T_ER_APPLYPROJECTOWER ( FID );

/**立项单 多语言 **/
 EXEC P_ALTERPK 'PK_ER_APPLYPROJECTBILL_L', 'T_ER_APPLYPROJECTBILL_L', 'FPKID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECT_L_FLCID') CREATE UNIQUE INDEX IDX_ER_APPLYPROJECT_L_FLCID ON T_ER_APPLYPROJECTBILL_L ( FID ,FLOCALEID );

/**立项单 分录**/
 EXEC P_ALTERPK 'PK_ER_APPLYPROJECTENTRY', 'T_ER_APPLYPROJECTENTRY', 'FENTRYID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECTENTRY_FSEQ') CREATE INDEX IDX_ER_APPLYPROJECTENTRY_FSEQ ON T_ER_APPLYPROJECTENTRY ( FID ,FSEQ );

/**立项单 **/
 EXEC P_ALTERPK 'PK_ER_APPLYPROJECTBILL', 'T_ER_APPLYPROJECTBILL', 'FID', '1';

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECT_FBNO') CREATE INDEX IDX_ER_APPLYPROJECT_FBNO ON T_ER_APPLYPROJECTBILL ( FBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECT_FBSTA') CREATE INDEX IDX_ER_APPLYPROJECT_FBSTA ON T_ER_APPLYPROJECTBILL ( FBILLSTATUS );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECT_FAPER') CREATE INDEX IDX_ER_APPLYPROJECT_FAPER ON T_ER_APPLYPROJECTBILL ( FAPPLIERID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECT_FDATE_NO') CREATE INDEX IDX_ER_APPLYPROJECT_FDATE_NO ON T_ER_APPLYPROJECTBILL ( FBIZDATE ,FBILLNO );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECT_FCREATEOR') CREATE INDEX IDX_ER_APPLYPROJECT_FCREATEOR ON T_ER_APPLYPROJECTBILL ( FCREATORID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_APPLYPROJECT_FCOMPANYID') CREATE INDEX IDX_ER_APPLYPROJECT_FCOMPANYID ON T_ER_APPLYPROJECTBILL ( FCOMPANYID );

/**End 立项单主键及索引 **/
