Initial version of collation migration scripts.
This commit is contained in:
61
docs/USAGE.md
Normal file
61
docs/USAGE.md
Normal file
@@ -0,0 +1,61 @@
|
||||
# Usage – Data Copy (Variant B / Checkpointing)
|
||||
|
||||
## Preconditions
|
||||
|
||||
1. **Target database exists** (e.g. UTF-8 collation)
|
||||
2. **Target schema is deployed** (tables, constraints, indexes, views, procs, triggers, users/roles etc.)
|
||||
3. You can connect to the SQL Server instance with sufficient permissions.
|
||||
|
||||
## Run
|
||||
|
||||
Open `scripts/migrate_copy_checkpoint.sql` in SSMS.
|
||||
|
||||
At the top configure:
|
||||
|
||||
- `@SourceDb` (default: `sysdb_UTF8`)
|
||||
- `@TargetDb` (default: `sysdb_utf8_jr`)
|
||||
|
||||
Optional behavior:
|
||||
|
||||
- `@Mode`
|
||||
- `RESUME` (default): skip tables already marked `DONE`
|
||||
- `RESET`: reset state and rerun all tables
|
||||
|
||||
- `@StopOnError`
|
||||
- `1` (default): stop on first table error
|
||||
- `0`: continue with next tables; check `dbo.MigrationState` afterwards
|
||||
|
||||
- `@BatchSize`
|
||||
- used for tables with `IDENTITY (int/bigint)` to copy in chunks
|
||||
|
||||
Execute the script.
|
||||
|
||||
## Monitoring
|
||||
|
||||
The script prints progress like:
|
||||
|
||||
- `... | TABLE_START | dbo.TableX`
|
||||
- `... | TABLE_DONE | dbo.TableX | Old=... New=...`
|
||||
- `... | TABLE_FAILED | dbo.TableX | Error ...`
|
||||
|
||||
In target DB you also have:
|
||||
|
||||
- `dbo.MigrationState` (table-level status)
|
||||
- `dbo.MigrationCopyLog` (append-only log)
|
||||
|
||||
Useful queries:
|
||||
|
||||
```sql
|
||||
USE sysdb_utf8_jr;
|
||||
SELECT * FROM dbo.MigrationState ORDER BY Status, TableSchema, TableName;
|
||||
SELECT TOP 200 * FROM dbo.MigrationCopyLog ORDER BY LogId DESC;
|
||||
```
|
||||
|
||||
## Rerun behavior
|
||||
|
||||
Each table is copied as:
|
||||
|
||||
1. `DELETE FROM target.table`
|
||||
2. `INSERT INTO target.table SELECT ... FROM source.table`
|
||||
|
||||
So reruns are safe. The checkpoint state enables resuming.
|
||||
49
docs/VERIFY.md
Normal file
49
docs/VERIFY.md
Normal file
@@ -0,0 +1,49 @@
|
||||
# Verify – Compare Source and Target
|
||||
|
||||
The script `scripts/compare_source_target.sql` compares **structure and high-level consistency** between two databases without comparing row contents.
|
||||
|
||||
## What is compared
|
||||
|
||||
1. **Rowcounts per table**
|
||||
2. **Columns**: datatype, length, nullable, collation
|
||||
3. **Programmable objects**: views, stored procedures, functions (hash of definition)
|
||||
4. **Triggers** (hash of definition)
|
||||
5. **Users/Roles**: principals existence + role memberships
|
||||
|
||||
## How to run
|
||||
|
||||
1. Open `scripts/compare_source_target.sql` in SSMS
|
||||
2. Set:
|
||||
- `@SourceDb` (default: `sysdb_UTF8`)
|
||||
- `@TargetDb` (default: `sysdb_utf8_jr`)
|
||||
3. Execute.
|
||||
|
||||
## Output style (quick to read)
|
||||
|
||||
### Live messages (SSMS Messages tab)
|
||||
|
||||
You get a human-readable summary per step, e.g.:
|
||||
|
||||
- `ROWCOUNTS | SourceTables=... TargetTables=... TablesWithRowDiff=...`
|
||||
- `COLUMNS | ColumnDiffs=...`
|
||||
- `MODULES | Differences=...`
|
||||
- `TRIGGERS | Differences=...`
|
||||
- `PRINCIPALS | Differences=...`
|
||||
- `ROLEMEMBERS | Differences=...`
|
||||
|
||||
At the end:
|
||||
|
||||
`COMPARE_DONE | RowDiffTables=... | ColumnDiffs=... | ...`
|
||||
|
||||
### Result sets (details)
|
||||
|
||||
If differences exist, result sets are shown for:
|
||||
|
||||
- Rowcount diffs
|
||||
- Column diffs
|
||||
- Module diffs
|
||||
- Trigger diffs
|
||||
- Principal diffs
|
||||
- Role membership diffs
|
||||
|
||||
If a section has **no differences**, you’ll see an `..._OK` message and no detail list.
|
||||
Reference in New Issue
Block a user