Skip to content

Added IsCdCEnabled to Get-DbaDatabase #9670

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

Open
wants to merge 3 commits into
base: development
Choose a base branch
from

Conversation

ReeceGoding
Copy link
Contributor

No attempt made to touch the Azure stuff.

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes Show if CDC is enabled in Get-DbaDatabase #9669 )
  • Breaking change (affects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (Invoke-ManualPester)
  • 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

Purpose

See #9669.

Approach

I did the first thing that came to mind and it immediately worked. I expected this to be much harder!

Commands to test

Get-DbaDatabase

Screenshots

image

@ReeceGoding ReeceGoding requested a review from niphlod May 20, 2025 18:35
@niphlod
Copy link
Contributor

niphlod commented May 20, 2025

ok, now the code is right but .... are we sure the column is there for every version ?
Feature-wise, I think CDC is from 2008 onwards, and restricted to enterprise only till 2016sp1.

@ReeceGoding
Copy link
Contributor Author

I thought the automated testing hit some really old versions?

@ReeceGoding
Copy link
Contributor Author

My old copy of SQL Server MVP Deep Dives Volume 1 agrees that it was new in 2008.

@ReeceGoding
Copy link
Contributor Author

We already have an if branch for major version 8. I doubt that any of this at all works for version before 8. And to my knowledge, 2008 is version 10. So I guess that I just need to write another branch for version 9 and then I'm done? Do you agree?

@ReeceGoding
Copy link
Contributor Author

@andreasjordan Aren't Change Tracking and CDC two different things?

@andreasjordan
Copy link
Contributor

@ReeceGoding yes, you are right. I was on the wrong track...

@andreasjordan
Copy link
Contributor

Maybe we should wrap $server.Query("SELECT name, state, SUSER_SNAME(owner_sid) AS [Owner], is_cdc_enabled FROM sys.databases") with a try catch and use the old query in the catch block.

@ReeceGoding
Copy link
Contributor Author

@niphlod @andreasjordan Better?

@andreasjordan
Copy link
Contributor

The code looks save now, thanks fo rthe change.

But we need to talk about the values. Should the property IsCdcEnabled be of type boolean? I can not test this at the moment, but your screenshot looks like it works on current versions, so the "bit" column type is converted to a boolean. But what about the old versions. The "0" in your query is likely just a number. Or should the query return $null as the feature is not availabe?

@ReeceGoding
Copy link
Contributor Author

Should the property IsCdcEnabled be of type boolean? I can not test this at the moment, but your screenshot looks like it works on current versions, so the "bit" column type is converted to a boolean. But what about the old versions. The "0" in your query is likely just a number. Or should the query return $null as the feature is not availabe?

I'm afraid that I don't know and also lack any way to find out. Suggestions?

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.

Show if CDC is enabled in Get-DbaDatabase
3 participants