Formats/Rivet.OperationResult.format.ps1xml

<?xml version="1.0" encoding="utf-8" ?>
<Configuration>
    <ViewDefinitions>
        <View>
            <Name>Rivet.OperationResult</Name>
            <ViewSelectedBy>
                <TypeName>Rivet.OperationResult</TypeName>
            </ViewSelectedBy>
            <GroupBy>
                <PropertyName>MigrationID</PropertyName>
                <CustomControlName>RivetOperationResult-GroupingFormat</CustomControlName>
            </GroupBy>
            <TableControl>
                <TableHeaders>
                    <TableColumnHeader>
                        <Label>Operation</Label>
                        <Width>24</Width>
                    </TableColumnHeader>
                    <TableColumnHeader>
                        <Label>Schema</Label>
                        <Width>10</Width>
                    </TableColumnHeader>
                    <TableColumnHeader>
                        <Label>Object</Label>
                    </TableColumnHeader>
                    <TableColumnHeader>
                        <Label>Details</Label>
                    </TableColumnHeader>
                </TableHeaders>
                <TableRowEntries>
                    <TableRowEntry>
                        <TableColumnItems>
                            <TableColumnItem>
                                <ScriptBlock>
                                    $_.Operation.GetType().Name -replace 'Operation$',''
                                </ScriptBlock>
                            </TableColumnItem>
                            <TableColumnItem>
                                <ScriptBlock>
                                    if( $_.Operation | Get-Member -Name 'SchemaName' )
                                    {
                                        $_.Operation.SchemaName
                                    }
                                </ScriptBlock>
                            </TableColumnItem>
                            <TableColumnItem>
                                <ScriptBlock>
                                    $op = $_.Operation
                                    $migration = $_.Migration
 
                                    if( ($op -is [Rivet.Operations.ExtendedPropertyOperation]) )
                                    {
                                        return $op.ObjectName
                                    }
 
                                    if( ($op | Get-Member -Name 'Name') )
                                    {
                                        $op.Name
                                    }
                                    elseif( ($op | Get-Member -Name 'TableName') )
                                    {
                                        $op.TableName
                                    }
                                    elseif( ($op | Get-Member -Name 'Path') )
                                    {
                                        if( -not $op.Path )
                                        {
                                            return
                                        }
 
                                        $migrationRoot = Split-Path -Parent -Path $migration.Path
                                        if( -not (Test-Path -Path $migrationRoot -PathType Container) -or -not (Test-Path -Path $op.Path -PathType Leaf) )
                                        {
                                            return Split-Path -Leaf -Path $op.Path
                                        }
 
                                        Push-Location -Path $migrationRoot -StackName 'RivetOperationView'
                                        try
                                        {
                                            Resolve-Path -Path $op.Path -Relative
                                        }
                                        finally
                                        {
                                            Pop-Location -StackName 'RivetOperationView'
                                        }
                                    }
                                </ScriptBlock>
                            </TableColumnItem>
                            <TableColumnItem>
                                <ScriptBlock>
                                    if( $_.RowsAffected -ge 0 )
                                    {
                                        return $_.RowsAffected
                                    }
 
                                    $op = $_.Operation
                                    if( $op -is [Rivet.Operations.RawDdlOperation] )
                                    {
                                        return $_.Query
                                    }
 
                                    if( ($op | Get-Member -Name 'NewName') )
                                    {
                                        return '=> {0}' -f $op.NewName
                                    }
 
                                    if( $op -is [Rivet.Operations.AddTableOperation] )
                                    {
                                        return $op.Columns
                                    }
 
                                    if( $op -is [Rivet.Operations.UpdateTableOperation] )
                                    {
                                        $op.AddColumns | ForEach-Object { '+{0}' -f $_ }
                                        $op.UpdateColumns
                                        $op.RemoveColumns | ForEach-Object { '-{0}' -f $_ }
                                        return
                                    }
 
                                    if( ($op | Get-Member -Name 'Value') )
                                    {
                                        return $op.Value
                                    }
                                </ScriptBlock>
                            </TableColumnItem>
                        </TableColumnItems>
                    </TableRowEntry>
                </TableRowEntries>
            </TableControl>
        </View>
    </ViewDefinitions>
</Configuration>