Files
workspace/code/fms/fms-api/config/migrations/README.md
T
2026-08-04 17:31:27 +08:00

29 lines
1.7 KiB
Markdown

# Database migrations
Module architecture cutover is manual and is not run during application startup.
Run against a backed-up `FMS` database in this order:
1. `033_create_module_structure.sql`
2. `034_module_runtime_views.sql`
3. `verify_module_architecture.sql`
`033` is a one-time transaction: it migrates valid metadata and removes the old metadata tables only after conversion checks pass. It intentionally does not create compatibility views or dual writes.
If the earlier intermediate implementation created only `s_module_profile`, `s_function_node`, or `s_page_node`, `033` verifies that the complete source model still exists and regenerates those derived tables inside the same transaction. Other partial target states are rejected.
`033` and `034` use SQL Server `GO` batch separators. Use SSMS, Azure Data Studio, `sqlcmd`, or another runner that understands `GO`.
`verify_module_architecture.sql` is a target-schema verification script. It does not modify application tables.
To check and conditionally apply `034` with the repository JDBC driver on Windows:
```powershell
$jdk = "D:\devtool\jdk\jdk-21\bin"
$driver = "tools\migration\mssql-jdbc-13.4.0.jre11.jar"
& "$jdk\javac.exe" -encoding UTF-8 -cp $driver -d $env:TEMP config\migrations\tools\ApplyModuleRuntimeViews.java
& "$jdk\java.exe" -cp "$env:TEMP;$driver" ApplyModuleRuntimeViews
```
The tool refuses non-`FMS` catalogs and executes `034` only when a required runtime view is missing.
For a database in the validated intermediate state, run `ApplyModuleRuntimeViews --dry-run-cutover` first. After verifying a database backup, `ApplyModuleRuntimeViews --apply-cutover` executes `033`, then conditionally executes `034` and verifies all required runtime views.