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

Feature/Remove-Constraint-Warnings #72

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

# Rivet Changelog

## 0.22.1

> Released 23 Oct 2023

* Removed warnings about missing constraint names.

## 0.22.0

> Released 6 Jul 2023
Expand Down
2 changes: 1 addition & 1 deletion Rivet/Functions/Convert-FileInfoToMigration.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function Convert-FileInfoToMigration
# Set CommandTimeout on operation to value from Rivet configuration.
$operationItem.CommandTimeout = $Session.CommandTimeout

$pluginParameter = @{ Migration = $Migration ; Operation = $_ }
$pluginParameter = @{ Migration = $Migration ; Operation = $operationItem }

[Rivet.Operations.Operation[]]$operations = & {
Invoke-RivetPlugin -Session $Session `
Expand Down
56 changes: 0 additions & 56 deletions Rivet/Functions/Repair-Operation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ function Repair-Operation
-SchemaName $schemaName `
-TableName $name `
-ColumnName $column.Name
Write-Warning -Message ('Column default constraint names will be required in a future version of ' +
"Rivet. Add a ""DefaultConstraintName"" parameter to the [$($Column.Name)] " +
"column on the $($operationName) operation for the " +
"[$($schemaName)].[$($name)] table.")
}
}
}
Expand All @@ -61,25 +57,12 @@ function Repair-Operation
$schemaName = $Operation | Select-Object -ExpandProperty 'SchemaName' -ErrorAction Ignore
$tableName = $Operation | Select-Object -ExpandProperty 'TableName' -ErrorAction Ignore
$columnName = $Operation | Select-Object -ExpandProperty 'ColumnName' -ErrorAction Ignore
$columnDesc = $columnName -join '", "'
$pluralSuffix = ''
if( ($columnName | Measure-Object).Count -gt 1 )
{
$pluralSuffix = 's'
}

$tableDesc = "[$($schemaName)].[$($tableName)]"

$warningMsg = ''

switch( $Operation.GetType().Name )
{
'AddDefaultConstraintOperation'
{
$Operation.Name = New-ConstraintName -Default -SchemaName $schemaName -TableName $tableName -ColumnName $columnName
$warningMsg = "Default constraint names will be required in a future version of Rivet. Add a " +
"""Name"" parameter (with a value of ""$($Operation.Name)"") to the Add-DefaultConstraint " +
"operation for the $($tableDesc) table's ""$($columnDesc)"" column."
}
'AddForeignKeyOperation'
{
Expand All @@ -88,23 +71,14 @@ function Repair-Operation
-TableName $tableName `
-ReferencesSchemaName $Operation.ReferencesSchemaName `
-ReferencesTableName $Operation.ReferencesTableName
$warningMsg = "Foreign key constraint names will be required in a future version of Rivet. " +
"Add a ""Name"" parameter (with a value of ""$($Operation.Name)"") to the Add-ForeignKey " +
"operation for the $($tableDesc) table's $($columnDesc) column$($pluralSuffix)."
}
'AddIndexOperation'
{
$Operation.Name = New-ConstraintName -Index -SchemaName $schemaName -TableName $tableName -ColumnName $columnName -Unique:$Operation.Unique
$warningMsg = "Index names will be required in a future version of Rivet. Add a ""Name"" " +
"parameter (with a value of ""$($Operation.Name)"") to the Add-Index operation for the " +
"$($tableDesc) table's ""$($columnDesc)"" column$($pluralSuffix)."
}
'AddPrimaryKeyOperation'
{
$Operation.Name = New-ConstraintName -PrimaryKey -SchemaName $schemaName -TableName $tableName
$warningMsg = "Primary key constraint names will be required in a future version of Rivet. " +
"Add a ""Name"" parameter (with a value of ""$($Operation.Name)"") to the Add-PrimaryKey " +
"operation for the $($tableDesc) table's $($columnDesc) column."
}
'AddTableOperation'
{
Expand All @@ -113,16 +87,10 @@ function Repair-Operation
'AddUniqueKeyOperation'
{
$Operation.Name = New-ConstraintName -UniqueKey -SchemaName $schemaName -TableName $tableName -ColumnName $columnName
$warningMsg = "Unique key constraint names will be required in a future version of Rivet. Add " +
"a ""Name"" parameter (with a value of ""$($Operation.Name)"") to the Add-UniqueKey " +
"operation on the $($tableDesc) table's $($columnDesc) column$($pluralSuffix)."
}
'RemoveDefaultConstraint'
{
$Operation.Name = New-ConstraintName -Default -SchemaName $schemaName -TableName $tableName -ColumnName $columnName
$warningMsg = "Default constraint names will be required in a future version of Rivet. Add a " +
"""Name"" parameter (with a value of ""$($Operation.Name)"") to the Remove-DefaultConstraint " +
"operation for the $($tableDesc) table's ""$($columnDesc)"" column."
}
'RemoveForeignKeyOperation'
{
Expand All @@ -131,49 +99,25 @@ function Repair-Operation
-TableName $tableName `
-ReferencesSchema $Operation.ReferencesSchema `
-ReferencesTableName $Operation.ReferencesTableName
$warningMsg = "Foreign key constraint names will be required in a future version of Rivet. " +
"Add a ""Name"" parameter (with a value of ""$($Operation.Name)"") to the Remove-ForeignKey " +
"operation for the $($tableDesc) table that references the " +
"[$($Operation.ReferencesSchemaName)].[$($Operation.ReferencesTableName)] table."
}
'RemoveIndexOperation'
{
$Operation.Name = New-ConstraintName -Index -SchemaName $schemaName -TableName $tableName -ColumnName $columnName -Unique:$Operation.Unique
$warningMsg = "Index names will be required in a future version of Rivet. Add a ""Name"" " +
"parameter (with a value of ""$($Operation.Name)"") to the Remove-Index operation for the " +
"$($tableDesc) table's ""$($columnDesc)"" column$($pluralSuffix)."
}
'RemovePrimaryKeyOperation'
{
$Operation.Name = New-ConstraintName -PrimaryKey -SchemaName $schemaName -TableName $tableName
$warningMsg = "Primay key constraint names will be required in a future version of Rivet. " +
"Add a ""Name"" parameter (with a value of ""$($Operation.Name)"") to the Remove-PrimaryKey " +
"operation for the $($tableDesc) table."
}
'RemoveUniqueKeyOperation'
{
$Operation.Name = New-ConstraintName -UniqueKey -SchemaName $schemaName -TableName $tableName -ColumnName $columnName
$warningMsg = "Unique key constraint names will be required in a future version of Rivet. " +
"Remove the ""ColumnName"" parameter and add a ""Name"" parameter (with a value of " +
"""$($Operation.Name)"") to the Remove-UniqueKey operation for the " +
"$($tableDesc) table's ""$($columnDesc)"" column$($pluralSuffix)."
}
'UpdateTableOperation'
{
$Operation.AddColumns | Repair-DefaultConstraintName
}
}

if( $warningMsg )
{
Write-Warning -Message $warningMsg
}

return $Operation
}

end
{

}
}
2 changes: 1 addition & 1 deletion Rivet/Rivet.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RootModule = 'Rivet.psm1'

# Version number of this module.
ModuleVersion = '0.22.0'
ModuleVersion = '0.22.1'

# ID used to uniquely identify this module
GUID = '8af34b47-259b-4630-a945-75d38c33b94d'
Expand Down
1 change: 0 additions & 1 deletion Test/RivetTest/Functions/Assert-DefaultConstraint.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ function Assert-DefaultConstraint

if( -not $Name )
{
Write-Warning ('Constructing constraint names will soon become obsolete. Please update usages of Assert-DefaultConstraint/ThenDefaultConstraint to pass the name of the constraint instead of the schema name, table name, and column names.')
$Name = New-RTConstraintName -ColumnName $ColumnName -TableName $TableName -SchemaName $SchemaName -Default
}

Expand Down