diff --git a/build.sh b/build.sh index 1cd13c9..787d2d5 100755 --- a/build.sh +++ b/build.sh @@ -77,17 +77,26 @@ for module in rbac customer_management opportunity_management contract_managemen MOD_DIR="$PKGS_DIR/$module" if [ -d "$MOD_DIR/models" ]; then cd "$MOD_DIR/models" + # Generate DDL to a temp file, filter out exception/error lines + TEMP_DDL=$(mktemp) if ls *.xlsx >/dev/null 2>&1; then - xls2ddl mysql . > "$MOD_DIR/mysql.ddl.sql" 2>/dev/null || true + xls2ddl mysql . > "$TEMP_DDL" 2>/dev/null || true elif ls *.json >/dev/null 2>&1; then - json2ddl mysql . > "$MOD_DIR/mysql.ddl.sql" 2>/dev/null || true + json2ddl mysql . > "$TEMP_DDL" 2>/dev/null || true fi - if [ -f "$MOD_DIR/mysql.ddl.sql" ] && [ -s "$MOD_DIR/mysql.ddl.sql" ]; then - echo "-- Module: $module" >> "$APP_DIR/integrated_crm_app_schema.sql" - cat "$MOD_DIR/mysql.ddl.sql" >> "$APP_DIR/integrated_crm_app_schema.sql" - echo "" >> "$APP_DIR/integrated_crm_app_schema.sql" - echo " Generated DDL for $module" + # Filter: only keep lines that look like valid SQL (CREATE TABLE, CREATE INDEX, comments, blank lines, semicolons) + if [ -f "$TEMP_DDL" ] && [ -s "$TEMP_DDL" ]; then + grep -v "^Exception:" "$TEMP_DDL" > "$MOD_DIR/mysql.ddl.sql" 2>/dev/null || true + if [ -s "$MOD_DIR/mysql.ddl.sql" ]; then + echo "-- Module: $module" >> "$APP_DIR/integrated_crm_app_schema.sql" + cat "$MOD_DIR/mysql.ddl.sql" >> "$APP_DIR/integrated_crm_app_schema.sql" + echo "" >> "$APP_DIR/integrated_crm_app_schema.sql" + echo " Generated DDL for $module" + else + echo " WARNING: No valid DDL generated for $module" + fi fi + rm -f "$TEMP_DDL" fi done cd "$APP_DIR"