Skip to content

Comments

Start-DbaMigration - Add -SetSourceOffline to set databases offline during migration#10013

Merged
potatoqualitee merged 14 commits intodevelopmentfrom
claude/issue-9156-20251128-1729
Dec 25, 2025
Merged

Start-DbaMigration - Add -SetSourceOffline to set databases offline during migration#10013
potatoqualitee merged 14 commits intodevelopmentfrom
claude/issue-9156-20251128-1729

Conversation

@potatoqualitee
Copy link
Member

Enhances the -SetSourceOffline parameter to work like -SetSourceReadOnly, setting databases offline BEFORE migration begins (not after) to prevent any connections to source databases during the migration process.

Closes #9156

Generated with Claude Code

…uring migration

This enhances the -SetSourceOffline parameter to work like -SetSourceReadOnly,
setting databases offline BEFORE migration begins (not after) to prevent any
connections to source databases during the migration process.

Changes:
- Start-DbaMigration.ps1: Added parameter and documentation
- Copy-DbaDatabase.ps1: Modified to set offline before migration, online on destination
- Tests updated to include new parameter in validation

(do Start-DbaMigration, Copy-DbaDatabase)

Co-authored-by: Chrissy LeMaire <[email protected]>
@potatoqualitee
Copy link
Member Author

@claude add an integration test

github-actions bot and others added 12 commits November 30, 2025 00:57
…eter

(do Start-DbaMigration)

Co-authored-by: Chrissy LeMaire <[email protected]>
(do Start-DbaMigration)

Co-authored-by: Chrissy LeMaire <[email protected]>
… verification

(do Start-DbaMigration)

Co-authored-by: Chrissy LeMaire <[email protected]>
Updated the role filtering logic in Copy-DbaServerRole to exclude the 'public' role in addition to fixed roles. This prevents unintended copying of the 'public' role to the target server.
Enhanced test setup and cleanup to handle offline databases and cross-platform backup paths. Added robust cleanup using T-SQL, improved backup directory handling for Linux/Docker, and refactored tests to ensure accurate migration and status checks. Also updated exclusions and variable usage for clarity and reliability.
SetSourceOffline is now applied before detach for DetachAttach and after backup for BackupRestore to ensure proper connection handling. Added integration tests to verify offline state after migration and cleanup logic for offline databases.

(do Start-DbaMigration)
Always use SQL Server's default backup directory for backups in Start-DbaMigration integration tests, removing OS-specific logic and cleanup. This ensures consistent access permissions and simplifies test setup and teardown.
Introduces removal of backup files created during Start-DbaMigration integration tests to ensure a cleaner test environment and prevent leftover files from affecting subsequent test runs.

(do Start-DbaMigration, Copy-DbaDatabase)
Reset Start-DbaMigration.Tests.ps1 and Copy-DbaDatabase.Tests.ps1 to their
development branch versions to establish a clean baseline before adding
new tests for SetSourceOffline parameter.

(do Start-DbaMigration, Copy-DbaDatabase)
@dataplat dataplat deleted a comment from claude bot Dec 25, 2025
@dataplat dataplat deleted a comment from claude bot Dec 25, 2025
@dataplat dataplat deleted a comment from claude bot Dec 25, 2025
Add integration tests to verify:
- Source database is set offline after successful migration
- Destination database is online/normal after migration

(do Start-DbaMigration)
@potatoqualitee potatoqualitee merged commit 3e09e73 into development Dec 25, 2025
14 checks passed
@potatoqualitee potatoqualitee deleted the claude/issue-9156-20251128-1729 branch December 25, 2025 22:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add -SetSourceOffline to Start-DbaMigration

1 participant