-
Notifications
You must be signed in to change notification settings - Fork 226
Add New-SqlDscDatabaseSnapshot command for SMO-based snapshot creation #2343
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
Merged
Merged
Changes from all commits
Commits
Show all changes
89 commits
Select commit
Hold shift + click to select a range
cd004e1
Initial plan
Copilot 9bf8d27
Add New-SqlDscDatabaseSnapshot command with tests
Copilot b4e92fd
Update CHANGELOG to remove placeholder issue reference
Copilot b0b1ad5
Add integration tests for New-SqlDscFileGroup and New-SqlDscDataFile …
johlju 18364c1
Add Add-SqlDscDataFile command with integration and unit tests
johlju d5a571d
Add FileGroup and DataFile classes with collections to manage databas…
johlju 58d605d
Add Add-SqlDscFileGroup command and associated tests for managing Fil…
johlju 964ff64
Add New-SqlDscDataFile command and associated tests for creating Data…
johlju 2348266
Add New-SqlDscFileGroup command and associated tests for creating Fil…
johlju ba30af5
Enhance New-SqlDscDatabaseSnapshot and related commands to support Fi…
johlju c0d43ba
Add Force parameter to New-SqlDscDataFile and New-SqlDscFileGroup for…
johlju 4be93c8
Fix OutputType attribute placement in New-SqlDscDataFile and New-SqlD…
johlju ce38251
Add tests for validating comment-based help structure and check for i…
johlju 0e68808
Add suppression for ScriptAnalyzer warning in Add-SqlDscDataFile func…
johlju 7fa7591
Add suppression for ScriptAnalyzer warning in Add-SqlDscFileGroup fun…
johlju 6d242ec
Add validation for Database object in New-SqlDscFileGroup function; t…
johlju 540de47
Add mock setup for Database object in New-SqlDscFileGroup integration…
johlju ea2b8b8
Refactor New-SqlDscDataFile function to simplify parameter handling a…
johlju 8cdb4ee
Enhance integration tests for Add-SqlDscDataFile and Add-SqlDscFileGr…
johlju 43d128f
Update CHANGELOG to reflect mandatory FileGroup parameter in New-SqlD…
johlju 2658deb
Update CHANGELOG and documentation for Add-SqlDscDataFile to support …
johlju f14707a
Refactor New-SqlDscFileGroup integration tests to create a real SMO D…
johlju 0877d60
Refactor integration tests for Add-SqlDscDataFile and Add-SqlDscFileG…
johlju ada3a7b
Add FileGroup parameter to New-SqlDscDatabase for custom file configu…
johlju 64e77ad
Remove Add-SqlDscDataFile function and its associated tests; deprecat…
johlju a904aaf
Enhance New-SqlDscDataFile to automatically add DataFile to FileGroup…
johlju a53f0c6
Refactor New-SqlDscDataFile integration tests to validate FileGroup f…
johlju d15f4e7
Remove deprecated Add-SqlDscDataFile integration test from pipeline c…
johlju 9030783
Refactor Add-SqlDscFileGroup integration tests to automatically creat…
johlju d410342
Remove `Add-SqlDscDataFile` command from changelog; deprecated functi…
johlju 2b13c4e
Add integration tests for creating a database with custom file groups…
johlju 0fdef27
Refactor example in New-SqlDscDatabase to use New-SqlDscFileGroup and…
johlju 2abd5ef
Refactor New-SqlDscDataFile function to streamline process handling a…
johlju 0b2442f
Merge branch 'main' into copilot/add-new-sqldscdatabase-snapshot
johlju 6dcd22e
Refactor New-SqlDscDataFile integration tests to use BeforeEach for s…
johlju b0751ce
Add terminal profile settings for Copilot in VSCode configuration
johlju c7df494
Add unit tests for DatabaseFileSpec and conversion functions
johlju ff88554
Add new commands and PowerShell classes for database file and file gr…
johlju 71d9956
Add file organization guidelines for classes and enums
johlju 0fcf82b
Add suppression message for ScriptAnalyzer rule in New-SqlDscFileGrou…
johlju 9de8739
Merge branch 'main' into copilot/add-new-sqldscdatabase-snapshot
johlju 720aea3
Add new commands and integration tests for converting DatabaseFileSpe…
johlju 5eace92
Add parameters for Size, MaxSize, Growth, GrowthType, and IsPrimaryFi…
johlju 3b361a8
Fix formatting in ConvertTo-SqlDscFileGroup integration tests
johlju 062bdff
Remove pipeline acceptance test for Database parameter in New-SqlDscF…
johlju 3dbc133
Refactor ConvertTo-SqlDscDataFile and ConvertTo-SqlDscFileGroup integ…
johlju 9ccc5df
Update parameter descriptions and usage for IsPrimaryFile in New-SqlD…
johlju 103a80b
Fix IsDefault parameter usage in New-SqlDscFileGroup calls in databas…
johlju 80abe5c
Add FileGroup parameter to New-SqlDscDatabaseSnapshot and update tests
johlju 8cc7a16
Add New-SqlDscDatabaseSnapshot integration tests to pipeline
johlju 714ec41
Remove test for Database parameter pipeline acceptance in New-SqlDscF…
johlju 30293f3
Add -Confirm:$false parameter to Add-SqlDscFileGroup to suppress conf…
johlju 5006eae
Remove test for Database parameter pipeline input acceptance in New-S…
johlju 3a461fe
Refactor tests in ConvertTo-SqlDscDataFile and ConvertTo-SqlDscFileGr…
johlju 434b68c
Remove unused mockComputerName variable and enhance snapshot file cre…
johlju d8e8d41
Add guideline to avoid using param() inside -MockWith scriptblocks
johlju 0078099
Add Force parameter to Add-SqlDscFileGroup and update related strings…
johlju 512a16f
Enhance documentation for ConvertTo-SqlDscDataFile by adding INPUTS s…
johlju 8be826e
Add Force parameter to New-SqlDscDataFile tests to bypass confirmatio…
johlju d1ffdc0
Add INPUTS section to Add-SqlDscFileGroup documentation for clarity
johlju 24ec742
Refactor New-SqlDscDatabaseSnapshot test to improve mock DatabaseFile…
johlju 72431a7
Add ErrorAction 'Stop' to Add-SqlDscFileGroup tests for improved erro…
johlju 8885a76
Refactor New-SqlDscDataFile tests to streamline assertions and improv…
johlju 0cabd5f
Remove verbose message for file group creation in New-SqlDscFileGroup…
johlju 20cf372
Enhance documentation for New-SqlDscDataFile parameters and outputs, …
johlju c0b239e
Remove PassThru parameter from New-SqlDscFileGroup function to stream…
johlju 0d77081
Enhance DatabaseFileGroupSpec tests to verify instance creation with …
johlju fc78845
Refactor BeforeAll and AfterAll blocks to streamline module import an…
johlju a64e736
Refactor DatabaseFileSpec tests to simplify instantiation checks by r…
johlju 2bd3c56
Fix comments and error messages in Add-SqlDscFileGroup tests for clarity
johlju 349b328
Refactor New-SqlDscFileGroup tests to eliminate InModuleScope usage f…
johlju 60bfadb
Add parameter set validation test for ConvertTo-SqlDscFileGroup command
johlju 12f1994
Refactor terminal profile settings in VSCode configuration for clarity
johlju 2737346
Update output documentation for cmdlets to clarify return types and c…
johlju 973dc55
Refactor DatabaseFileGroupSpec tests to improve variable scoping and …
johlju 1bcc175
Add input documentation and validation for DataFileSpec parameter in …
johlju 123856e
Return FileGroup object when PassThru parameter is specified in Add-S…
johlju 43fdbc5
Update New-SqlDscFileGroup to set 'Standalone' as the default paramet…
johlju ae8a1b6
Add input documentation for New-SqlDscFileGroup and update FileGroupS…
johlju 3127195
Add tests for New-SqlDscFileGroup to validate FileGroupSpec creation …
johlju 93f434e
Return FileGroup object when PassThru parameter is specified in Add-S…
johlju c6ac9a0
Refactor variable names for consistency in New-SqlDscDataFile.Tests.ps1
johlju bcaa6fa
Add automatic file group generation in New-SqlDscDatabaseSnapshot whe…
johlju 3dea101
Refactor New-SqlDscDatabaseSnapshot to use New-SqlDscDataFile and New…
johlju 3cf2e5a
Refactor New-SqlDscDatabaseSnapshot.Tests.ps1 to use platform-specifi…
johlju 4a4b5d6
Add cleanup logic for existing snapshots in New-SqlDscDatabaseSnapsho…
johlju 87353f5
Move verbose logging for database snapshot creation to the end of the…
johlju 4b60a75
Add cleanup logic for database snapshots in AfterEach blocks of integ…
johlju baafa8d
Enhance documentation for New-SqlDscDatabaseSnapshot cmdlet to clarif…
johlju File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Defines a data file specification for a database file group. | ||
|
|
||
| .DESCRIPTION | ||
| This class represents a data file specification that can be used when | ||
| creating a new database. It contains the properties needed to define | ||
| a data file without requiring an existing database or file group SMO object. | ||
|
|
||
| .PARAMETER Name | ||
| The logical name of the data file. | ||
|
|
||
| .PARAMETER FileName | ||
| The physical file path for the data file. This must be a valid path | ||
| on the SQL Server instance. | ||
|
|
||
| .PARAMETER Size | ||
| The initial size of the data file in kilobytes. If not specified, | ||
| SQL Server will use its default initial size. | ||
|
|
||
| .PARAMETER MaxSize | ||
| The maximum size to which the data file can grow in kilobytes. | ||
| If not specified, the file can grow without limit (or up to disk space). | ||
|
|
||
| .PARAMETER Growth | ||
| The amount by which the data file grows when it needs more space. | ||
| The value is in kilobytes if GrowthType is KB, or a percentage if | ||
| GrowthType is Percent. If not specified, SQL Server will use its | ||
| default growth setting. | ||
|
|
||
| .PARAMETER GrowthType | ||
| Specifies whether the Growth value is in kilobytes (KB) or percent (Percent). | ||
| If not specified, defaults to KB. | ||
|
|
||
| .PARAMETER IsPrimaryFile | ||
| Specifies that this file is the primary file in the PRIMARY file group. | ||
| Only one file in the PRIMARY file group should be marked as the primary file. | ||
| This property is typically used for the first file in the PRIMARY file group. | ||
|
|
||
| .NOTES | ||
| This class is used to specify data file configurations when creating a new | ||
| database via New-SqlDscDatabase. Unlike SMO DataFile objects, these | ||
| specification objects can be created without an existing database context. | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| .EXAMPLE | ||
| $fileSpec = [DatabaseFileSpec]::new() | ||
| $fileSpec.Name = 'MyDatabase_Data' | ||
| $fileSpec.FileName = 'C:\SQLData\MyDatabase.mdf' | ||
| $fileSpec.Size = 102400 # 100 MB in KB | ||
| $fileSpec.Growth = 10240 # 10 MB in KB | ||
| $fileSpec.GrowthType = 'KB' | ||
|
|
||
| Creates a new data file specification with a specific size and growth settings. | ||
|
|
||
| .EXAMPLE | ||
| [DatabaseFileSpec] @{ | ||
| Name = 'MyDatabase_Data' | ||
| FileName = 'C:\SQLData\MyDatabase.mdf' | ||
| IsPrimaryFile = $true | ||
| } | ||
|
|
||
| Creates a new primary data file specification using hashtable syntax. | ||
| #> | ||
| class DatabaseFileSpec | ||
| { | ||
| [System.String] | ||
| $Name | ||
|
|
||
| [System.String] | ||
| $FileName | ||
|
|
||
| [System.Nullable[System.Double]] | ||
| $Size | ||
|
|
||
| [System.Nullable[System.Double]] | ||
| $MaxSize | ||
|
|
||
| [System.Nullable[System.Double]] | ||
| $Growth | ||
|
|
||
| [ValidateSet('KB', 'MB', 'Percent')] | ||
| [System.String] | ||
| $GrowthType | ||
|
|
||
| [System.Boolean] | ||
| $IsPrimaryFile = $false | ||
|
|
||
| DatabaseFileSpec() | ||
| { | ||
| } | ||
|
|
||
| DatabaseFileSpec([System.String] $name, [System.String] $fileName) | ||
| { | ||
| $this.Name = $name | ||
| $this.FileName = $fileName | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| <# | ||
| .SYNOPSIS | ||
| Defines a file group specification for a database. | ||
|
|
||
| .DESCRIPTION | ||
| This class represents a file group specification that can be used when | ||
| creating a new database. It contains the properties needed to define | ||
| a file group and its associated data files without requiring an existing | ||
| database SMO object. | ||
|
|
||
| .PARAMETER Name | ||
| The name of the file group. For the primary file group, this should be 'PRIMARY'. | ||
|
|
||
| .PARAMETER Files | ||
| An array of DatabaseFileSpec objects that define the data files belonging | ||
| to this file group. At least one file must be specified for each file group. | ||
|
|
||
| .PARAMETER ReadOnly | ||
| Specifies whether the file group is read-only. If not specified, defaults | ||
| to $false (read-write). | ||
|
|
||
| .PARAMETER IsDefault | ||
| Specifies whether this file group should be the default file group for | ||
| new objects. If not specified, defaults to $false. Typically, only the | ||
| PRIMARY file group or one custom file group should be marked as default. | ||
|
|
||
| .NOTES | ||
| This class is used to specify file group configurations when creating a new | ||
| database via New-SqlDscDatabase. Unlike SMO FileGroup objects, these | ||
| specification objects can be created without an existing database context. | ||
|
|
||
| When creating a database, you typically need at least one file group named | ||
| 'PRIMARY' which contains the primary data file. Additional file groups can | ||
| be added for organizing data files. | ||
|
johlju marked this conversation as resolved.
|
||
|
|
||
| .EXAMPLE | ||
| $primaryFile = [DatabaseFileSpec] @{ | ||
| Name = 'MyDatabase_Primary' | ||
| FileName = 'C:\SQLData\MyDatabase.mdf' | ||
| IsPrimaryFile = $true | ||
| } | ||
|
|
||
| $primaryFileGroup = [DatabaseFileGroupSpec]::new() | ||
| $primaryFileGroup.Name = 'PRIMARY' | ||
| $primaryFileGroup.Files = @($primaryFile) | ||
|
|
||
| Creates a PRIMARY file group specification with one primary data file. | ||
|
|
||
| .EXAMPLE | ||
| $dataFile1 = [DatabaseFileSpec] @{ | ||
| Name = 'MyDatabase_Data1' | ||
| FileName = 'D:\SQLData\MyDatabase_Data1.ndf' | ||
| Size = 204800 # 200 MB | ||
| } | ||
|
|
||
| $dataFile2 = [DatabaseFileSpec] @{ | ||
| Name = 'MyDatabase_Data2' | ||
| FileName = 'D:\SQLData\MyDatabase_Data2.ndf' | ||
| Size = 204800 # 200 MB | ||
| } | ||
|
|
||
| $secondaryFileGroup = [DatabaseFileGroupSpec] @{ | ||
| Name = 'SECONDARY' | ||
| Files = @($dataFile1, $dataFile2) | ||
| } | ||
|
|
||
| Creates a SECONDARY file group specification with two data files. | ||
|
|
||
| .EXAMPLE | ||
| [DatabaseFileGroupSpec] @{ | ||
| Name = 'PRIMARY' | ||
| Files = @( | ||
| [DatabaseFileSpec] @{ | ||
| Name = 'MyDB_Primary' | ||
| FileName = 'C:\SQLData\MyDB.mdf' | ||
| } | ||
| ) | ||
| } | ||
|
|
||
| Creates a PRIMARY file group using hashtable syntax with an embedded file spec. | ||
| #> | ||
| class DatabaseFileGroupSpec | ||
| { | ||
| [System.String] | ||
| $Name | ||
|
|
||
| [DatabaseFileSpec[]] | ||
| $Files | ||
|
|
||
| [System.Boolean] | ||
| $ReadOnly = $false | ||
|
|
||
| [System.Boolean] | ||
| $IsDefault = $false | ||
|
|
||
| DatabaseFileGroupSpec() | ||
| { | ||
| } | ||
|
|
||
| DatabaseFileGroupSpec([System.String] $name) | ||
| { | ||
| $this.Name = $name | ||
| } | ||
|
|
||
| DatabaseFileGroupSpec([System.String] $name, [DatabaseFileSpec[]] $files) | ||
| { | ||
| $this.Name = $name | ||
| $this.Files = $files | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.