# Drop Jeecg demo/sample tables from inquiry_robot; keep sys_*/onl_*/QRTZ_*/jimu_*. $ErrorActionPreference = "Continue" $mysql = "C:\yutongda\tools\mysql-8.0.39-winx64\bin\mysql.exe" $envFile = "E:\wwwroot\.env" $hostn = "10.206.0.15"; $user = "inquiry_robot"; $pass = $null; $db = "inquiry_robot" Get-Content $envFile | ForEach-Object { if ($_ -match '^MYSQL_HOST=(.+)$') { $hostn = $Matches[1].Trim() } if ($_ -match '^MYSQL_USER=(.+)$') { $user = $Matches[1].Trim() } if ($_ -match '^MYSQL_PASSWORD=(.+)$') { $pass = $Matches[1].Trim() } if ($_ -match '^MYSQL_DB=(.+)$') { $db = $Matches[1].Trim() } } if ($db -ne "inquiry_robot") { throw "refuse db=$db" } $drop = @( "ceshi_note", "demo", "demo_field_def_val_main", "demo_field_def_val_sub", "sys_gateway_route", "test_demo", "test_enhance_select", "test_note", "test_order_customer", "test_order_main", "test_order_product", "test_shoptype_tree", "test_v3_hello", "jeecg_monthly_growth_analysis", "jeecg_order_customer", "jeecg_order_main", "jeecg_order_ticket", "jeecg_project_nature_income", "joa_demo", "tmp_report_data_1", "tmp_report_data_income" ) $sql = "SET FOREIGN_KEY_CHECKS=0;`n" foreach ($t in $drop) { $sql += "DROP TABLE IF EXISTS ``$t``;`n" } $sql += "SET FOREIGN_KEY_CHECKS=1;`n" $sql += "SELECT COUNT(*) AS table_count FROM information_schema.tables WHERE table_schema=DATABASE();`n" $sqlFile = "E:\wwwroot\ops\sql\_drop_jeecg_demo.sql" Set-Content $sqlFile -Value $sql -Encoding ascii $out = & $mysql -h $hostn -P 3306 -u $user "-p$pass" $db -e "source $($sqlFile -replace '\\','/')" 2>&1 $out | ForEach-Object { if ($_ -match "Warning|password") { return } "$_" } # recount classes $tables = & $mysql -h $hostn -P 3306 -u $user "-p$pass" --batch -N $db -e "SHOW TABLES" 2>&1 | ForEach-Object {"$_".Trim()} | Where-Object { $_ -ne "" -and $_ -notmatch "Warning" } Write-Output ("remaining_total=" + @($tables).Count) $tables | ForEach-Object { $_ } Write-Output "CLEAN_OK"