docs & tools: Actualización de informes y scripts de migración DASUTEN
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/env ruby
|
||||
# frozen_string_literal: true
|
||||
|
||||
require_relative 'drones/lib/dasu_executor'
|
||||
|
||||
puts "=== DASU-SQL4 - Verificar triggers y constraints en BonosAfiliado ==="
|
||||
puts ""
|
||||
|
||||
ps_script = <<~PSCMD.strip
|
||||
$ErrorActionPreference = "Stop"
|
||||
$connString = "Server=localhost;Database=sysdasuten;Integrated Security=true;TrustServerCertificate=yes;"
|
||||
$conn = New-Object System.Data.SqlClient.SqlConnection($connString)
|
||||
$conn.Open()
|
||||
|
||||
Write-Host "[1] ¿Hay triggers en BonosAfiliado?"
|
||||
$cmd = New-Object System.Data.SqlClient.SqlCommand("
|
||||
SELECT name, type_desc
|
||||
FROM sys.triggers
|
||||
WHERE parent_id = OBJECT_ID('dbo.BonosAfiliado')
|
||||
", $conn)
|
||||
$adapter = New-Object System.Data.SqlClient.SqlDataAdapter($cmd)
|
||||
$ds = New-Object System.Data.DataSet
|
||||
$adapter.Fill($ds)
|
||||
if ($ds.Tables[0].Rows.Count -gt 0) {
|
||||
$ds.Tables[0].Rows | ForEach-Object {
|
||||
Write-Host " Trigger: $($_.name) ($($_.type_desc))"
|
||||
}
|
||||
} else {
|
||||
Write-Host " No hay triggers"
|
||||
}
|
||||
|
||||
Write-Host "`n[2] Constraints DEFAULT en idsolicitud:"
|
||||
$cmd = New-Object System.Data.SqlClient.SqlCommand("
|
||||
SELECT dc.name, dc.definition
|
||||
FROM sys.default_constraints dc
|
||||
JOIN sys.columns c ON dc.parent_object_id = c.object_id AND dc.parent_column_id = c.column_id
|
||||
WHERE OBJECT_NAME(dc.parent_object_id) = 'BonosAfiliado' AND c.name = 'idsolicitud'
|
||||
", $conn)
|
||||
$adapter = New-Object System.Data.SqlClient.SqlDataAdapter($cmd)
|
||||
$ds = New-Object System.Data.DataSet
|
||||
$adapter.Fill($ds)
|
||||
if ($ds.Tables[0].Rows.Count -gt 0) {
|
||||
$ds.Tables[0].Rows | ForEach-Object {
|
||||
Write-Host " Constraint: $($_.name) = $($_.definition)"
|
||||
}
|
||||
} else {
|
||||
Write-Host " No hay constraints DEFAULT"
|
||||
}
|
||||
|
||||
Write-Host "`n[3] Verificar columna idsolicitud (detalles):"
|
||||
$cmd = New-Object System.Data.SqlClient.SqlCommand("
|
||||
SELECT
|
||||
c.name,
|
||||
c.is_nullable,
|
||||
c.is_identity,
|
||||
c.default_object_id,
|
||||
t.name as type_name
|
||||
FROM sys.columns c
|
||||
JOIN sys.types t ON c.user_type_id = t.user_type_id
|
||||
WHERE c.object_id = OBJECT_ID('dbo.BonosAfiliado') AND c.name = 'idsolicitud'
|
||||
", $conn)
|
||||
$adapter = New-Object System.Data.SqlClient.SqlDataAdapter($cmd)
|
||||
$ds = New-Object System.Data.DataSet
|
||||
$adapter.Fill($ds)
|
||||
if ($ds.Tables[0].Rows.Count -gt 0) {
|
||||
$row = $ds.Tables[0].Rows[0]
|
||||
Write-Host " name: $($row.name)"
|
||||
Write-Host " is_nullable: $($row.is_nullable)"
|
||||
Write-Host " is_identity: $($row.is_identity)"
|
||||
Write-Host " default_object_id: $($row.default_object_id)"
|
||||
Write-Host " type: $($row.type_name)"
|
||||
}
|
||||
|
||||
$conn.Close()
|
||||
PSCMD
|
||||
|
||||
DasuExecutor.execute_ps_on_dasu(ps_script)
|
||||
|
||||
puts "\n✅ Verificación completada"
|
||||
Reference in New Issue
Block a user