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

namespace Exferia_EntityFramework.Script_Actualizacion
{
    class Scripts_Version_1246
    {
        public static Version G_VRS_VERSION = new Version("1.2.4.6");
        public static long G_LNG_VERSION = 1246;
        public static int G_INT_TIPO = 0;
        public static string G_STR_SCRIPT =
                                     //BORRAR campo idCobro a la tabla VTA_CobrosRecargosIntereses
                                     "IF exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='idCobro' AND TABLE_NAME = 'VTA_CobrosRecargosIntereses' " +
                                      ") " +
                                    "BEGIN " +
                                        " ALTER TABLE VTA_CobrosRecargosIntereses DROP CONSTRAINT[FK_VTA_CobrosRecargosIntereses_VTA_Cobros] " +
                                        " ALTER TABLE VTA_CobrosRecargosIntereses DROP COLUMN [idCobro] " +
                                    "END " +
                                    //AÑADIR campo idRemesaLinea a la tabla VTA_CobrosRecargosIntereses
                                    " IF not exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='idRemesaLinea' AND TABLE_NAME = 'VTA_CobrosRecargosIntereses' " +
                                      ") " +
                                    " BEGIN " +
                                        " ALTER TABLE [VTA_CobrosRecargosIntereses]ADD[idRemesaLinea] bigint NULL  " +
                                        //Relaciones
                                        " ALTER TABLE[dbo].[VTA_CobrosRecargosIntereses] WITH CHECK ADD CONSTRAINT[FK_VTA_CobrosRecargosIntereses_VTA_RemesasLinea] FOREIGN KEY([idRemesaLinea]) REFERENCES[dbo].[VTA_RemesasLinea] ([id]) " +
                                        " ALTER TABLE[dbo].[VTA_CobrosRecargosIntereses] CHECK CONSTRAINT[FK_VTA_CobrosRecargosIntereses_VTA_RemesasLinea] " +

                                    " END ";





    }
}
