Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add-DbaAgDatabase - Use ExecuteAs with restore to set correct database owner #9144

Merged
merged 1 commit into from
Oct 29, 2023

Conversation

andreasjordan
Copy link
Contributor

Please read -- recent changes to our repo

On November 10, 2022, we removed some bloat from our repository (for the second and final time). This change requires that all contributors reclone or refork their repo.

PRs from repos that have not been recently reforked or recloned will be closed and @potatoqualitee will cherry-pick your commits and open a new PR with your changes.

  • Please confirm you have the smaller repo (85MB .git directory vs 275MB or 110MB or 185MB .git directory)

Type of Change

  • Bug fix (non-breaking change, fixes Add-DbaAgDatabase - support setting owner of database to another login #9105 )
  • New feature (non-breaking change, adds functionality, fixes # )
  • Breaking change (affects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (.\tests\manual.pester.ps1)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/dataplat/appveyor-lab ?
  • Unit test is included
  • Documentation
  • Build system

Before using the new code path, we test two things:

  • Would the owner of the replica database be different from the original owner?
  • Is the original owner a login on the replica?
    If both are true, we use ExecuteAs with Restore-DbaDatabase to use the same owner on the replica.

This way we ensure the best practice setting that the databases should have the same owner on all replicas without a need for a code change for current users. I like this way better than implementing another parameter.

@potatoqualitee
Copy link
Member

this is beautiful! are there any version or parameter limitations limitations on executeas?

@andreasjordan
Copy link
Contributor Author

No, I don't think so. All it does is a $script = "EXECUTE AS LOGIN='$ExecuteAs'; " + $script inside of Invoke-DbaAdvancedRestore.

@potatoqualitee potatoqualitee merged commit 818dd39 into development Oct 29, 2023
11 checks passed
@potatoqualitee potatoqualitee deleted the AddDbaAgDatabase_set_correct_owner branch October 29, 2023 18:04
@potatoqualitee
Copy link
Member

ty!

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-DbaAgDatabase - support setting owner of database to another login
2 participants