| | |
| | | # Usage: |
| | | # .\scripts\reset-test-db.ps1 |
| | | # .\scripts\reset-test-db.ps1 -Database talent_card_test -Port 8134 -User root -Password 123456 |
| | | # .\scripts\reset-test-db.ps1 -Database talent_card # reset another schema on the same server |
| | | # |
| | | # The dev schema (talent_card) is refused on purpose: it holds tables that no migration creates |
| | | # (hand-made in the shared dev database), so dropping them loses data that cannot be rebuilt from |
| | | # db/migration. See "不要重建开发库" in docs/agents/testing.md. |
| | | param( |
| | | [string] $Database = '', |
| | | [string] $DatabaseHost = '', |
| | |
| | | if (-not $User) { $User = if ($env:TEST_DATASOURCE_USERNAME) { $env:TEST_DATASOURCE_USERNAME } else { 'root' } } |
| | | if (-not $Password) { $Password = if ($env:TEST_DATASOURCE_PASSWORD) { $env:TEST_DATASOURCE_PASSWORD } else { '123456' } } |
| | | |
| | | if ($Database -eq 'talent_card') { |
| | | throw "拒绝重置开发库 talent_card:它含有迁移从未创建的历史表(如 dependent_card_apply、merchant_benefit_rule),删表会丢数据且无法从 db/migration 重建。详见 docs/agents/testing.md。" |
| | | } |
| | | |
| | | $driver = Find-MySqlDriver |
| | | if (-not $driver) { |
| | | throw 'mysql-connector-j was not found in the Maven local repository. Run ".\mvnw.cmd -o test-compile" once so Maven downloads the project dependencies.' |