using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exferia_EntityFramework.Script_Actualizacion
{
    class Scripts_Version_1294
    {
        public static Version G_VRS_VERSION = new Version("1.2.9.4");
        public static long G_LNG_VERSION = 1294;
        public static int G_INT_TIPO = 0;
        public static string G_STR_SCRIPT =
                                     //MODIFICAR campo estado a la tabla PER_NominasVencimientos
                                     "IF exists " +
                                      "( " +
                                       "     SELECT * " +
                                       "     FROM INFORMATION_SCHEMA.COLUMNS " +
                                       "     WHERE COLUMN_NAME = 'estado' AND TABLE_NAME = 'PER_NominasVencimientos' AND IS_NULLABLE='YES' " +
                                      ") " +
                                    "BEGIN " +
                                        " UPDATE [PER_NominasVencimientos] SET estado='C'  " +
                                        " ALTER TABLE[PER_NominasVencimientos] ALTER COLUMN[estado] VARCHAR(1) NOT NULL " +
                                    "END " +
                                     //AÑADIR campo idTesoreria a la tabla MAE_Empleados
                                     "IF not exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='idTesoreria' AND TABLE_NAME = 'MAE_Empleados' " +
                                      ") " +
                                    "BEGIN " +
                                        " ALTER TABLE [MAE_Empleados]ADD[idTesoreria] bigint NULL  " +
                                        //Relaciones
                                        " ALTER TABLE[MAE_Empleados] WITH CHECK ADD  CONSTRAINT[FK_MAE_Empleados_MAE_Tesorerias] FOREIGN KEY([idTesoreria]) REFERENCES[MAE_Tesorerias] ([id]) " +
                                        " ALTER TABLE[MAE_Empleados] CHECK CONSTRAINT[FK_MAE_Empleados_MAE_Tesorerias] " +
                                    "END " +
                                     //BORRAR campo idProveedor a la tabla PER_Nominas
                                     "IF exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='idProveedor' AND TABLE_NAME = 'PER_Nominas' " +
                                      ") " +
                                    "BEGIN " +
                                        " ALTER TABLE PER_Nominas DROP CONSTRAINT[FK_PER_Nominas_MAE_Proveedores] " +
                                        " ALTER TABLE PER_Nominas DROP COLUMN [idProveedor] " +
                                    "END ";









    }
}
