|
| 1 | +<# |
| 2 | + .SYNOPSIS |
| 3 | + Defines a data file specification for a database file group. |
| 4 | +
|
| 5 | + .DESCRIPTION |
| 6 | + This class represents a data file specification that can be used when |
| 7 | + creating a new database. It contains the properties needed to define |
| 8 | + a data file without requiring an existing database or file group SMO object. |
| 9 | +
|
| 10 | + .PARAMETER Name |
| 11 | + The logical name of the data file. |
| 12 | +
|
| 13 | + .PARAMETER FileName |
| 14 | + The physical file path for the data file. This must be a valid path |
| 15 | + on the SQL Server instance. |
| 16 | +
|
| 17 | + .PARAMETER Size |
| 18 | + The initial size of the data file in kilobytes. If not specified, |
| 19 | + SQL Server will use its default initial size. |
| 20 | +
|
| 21 | + .PARAMETER MaxSize |
| 22 | + The maximum size to which the data file can grow in kilobytes. |
| 23 | + If not specified, the file can grow without limit (or up to disk space). |
| 24 | +
|
| 25 | + .PARAMETER Growth |
| 26 | + The amount by which the data file grows when it needs more space. |
| 27 | + The value is in kilobytes if GrowthType is KB, or a percentage if |
| 28 | + GrowthType is Percent. If not specified, SQL Server will use its |
| 29 | + default growth setting. |
| 30 | +
|
| 31 | + .PARAMETER GrowthType |
| 32 | + Specifies whether the Growth value is in kilobytes (KB) or percent (Percent). |
| 33 | + If not specified, defaults to KB. |
| 34 | +
|
| 35 | + .PARAMETER IsPrimaryFile |
| 36 | + Specifies that this file is the primary file in the PRIMARY file group. |
| 37 | + Only one file in the PRIMARY file group should be marked as the primary file. |
| 38 | + This property is typically used for the first file in the PRIMARY file group. |
| 39 | +
|
| 40 | + .NOTES |
| 41 | + This class is used to specify data file configurations when creating a new |
| 42 | + database via New-SqlDscDatabase. Unlike SMO DataFile objects, these |
| 43 | + specification objects can be created without an existing database context. |
| 44 | +
|
| 45 | + .EXAMPLE |
| 46 | + $fileSpec = [DatabaseFileSpec]::new() |
| 47 | + $fileSpec.Name = 'MyDatabase_Data' |
| 48 | + $fileSpec.FileName = 'C:\SQLData\MyDatabase.mdf' |
| 49 | + $fileSpec.Size = 102400 # 100 MB in KB |
| 50 | + $fileSpec.Growth = 10240 # 10 MB in KB |
| 51 | + $fileSpec.GrowthType = 'KB' |
| 52 | +
|
| 53 | + Creates a new data file specification with a specific size and growth settings. |
| 54 | +
|
| 55 | + .EXAMPLE |
| 56 | + [DatabaseFileSpec] @{ |
| 57 | + Name = 'MyDatabase_Data' |
| 58 | + FileName = 'C:\SQLData\MyDatabase.mdf' |
| 59 | + IsPrimaryFile = $true |
| 60 | + } |
| 61 | +
|
| 62 | + Creates a new primary data file specification using hashtable syntax. |
| 63 | +#> |
| 64 | +class DatabaseFileSpec |
| 65 | +{ |
| 66 | + [System.String] |
| 67 | + $Name |
| 68 | + |
| 69 | + [System.String] |
| 70 | + $FileName |
| 71 | + |
| 72 | + [System.Nullable[System.Double]] |
| 73 | + $Size |
| 74 | + |
| 75 | + [System.Nullable[System.Double]] |
| 76 | + $MaxSize |
| 77 | + |
| 78 | + [System.Nullable[System.Double]] |
| 79 | + $Growth |
| 80 | + |
| 81 | + [ValidateSet('KB', 'MB', 'Percent')] |
| 82 | + [System.String] |
| 83 | + $GrowthType |
| 84 | + |
| 85 | + [System.Boolean] |
| 86 | + $IsPrimaryFile = $false |
| 87 | + |
| 88 | + DatabaseFileSpec() |
| 89 | + { |
| 90 | + } |
| 91 | + |
| 92 | + DatabaseFileSpec([System.String] $name, [System.String] $fileName) |
| 93 | + { |
| 94 | + $this.Name = $name |
| 95 | + $this.FileName = $fileName |
| 96 | + } |
| 97 | +} |
0 commit comments