using Exferia_Aplicacion.General;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Exferia_Aplicacion.General.Enumerados;

namespace Exferia_EntityFramework.Script_Actualizacion
{
    public class Scripts_Version_1154
    {
        public static Version G_VRS_VERSION = new Version("1.1.5.4");
        public static long G_LNG_VERSION = 1154;
        public static int G_INT_TIPO = 0;
        public static string G_STR_SCRIPT =
                                //AGREGAR BORRADO EN CASCADA EN LA TABLA DE PRV_ArbolPrincipal_Imagenes 
                                " IF exists " +
                                " ( " +
                                    " SELECT * " +
                                    " FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS " +
                                    " WHERE (CONSTRAINT_NAME = 'FK_PRV_ArbolPrincipal_Imagenes_PRV_ArbolPrincipal') " +
                                " )  " +
                                " BEGIN " +
                                    //Borrar relación antigua
                                    " ALTER TABLE PRV_ArbolPrincipal_Imagenes DROP CONSTRAINT[FK_PRV_ArbolPrincipal_Imagenes_PRV_ArbolPrincipal] " +
                                    //Crear la Nueva
                                    " ALTER TABLE PRV_ArbolPrincipal_Imagenes WITH CHECK ADD CONSTRAINT[FK_PRV_ArbolPrincipal_Imagenes_PRV_ArbolPrincipal_1] FOREIGN KEY(idArbolPrincipal) REFERENCES[PRV_ArbolPrincipal] (id) ON DELETE CASCADE " +
                                    " ALTER TABLE PRV_ArbolPrincipal_Imagenes CHECK CONSTRAINT[FK_PRV_ArbolPrincipal_Imagenes_PRV_ArbolPrincipal_1] " +
                                " END " +
                                //AGREGAR BORRADO EN CASCADA EN LA TABLA DE PRV_ArbolPrincipal_Imagenes_USR_Usuarios 
                                " IF exists " +
                                " ( " +
                                    " SELECT * " +
                                    " FROM INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS " +
                                    " WHERE (CONSTRAINT_NAME = 'FK_PRV_ArbolPrincipal_Imagenes_USR_Usuarios_PRV_ArbolPrincipal_USR_Usuarios') " +
                                " )  " +
                                " BEGIN " +
                                    //Borrar relación antigua
                                    " ALTER TABLE PRV_ArbolPrincipal_Imagenes_USR_Usuarios DROP CONSTRAINT[FK_PRV_ArbolPrincipal_Imagenes_USR_Usuarios_PRV_ArbolPrincipal_USR_Usuarios] " +
                                    //Crear la Nueva
                                    " ALTER TABLE PRV_ArbolPrincipal_Imagenes_USR_Usuarios WITH CHECK ADD CONSTRAINT[FK_PRV_ArbolPrincipal_Imagenes_USR_Usuarios_PRV_ArbolPrincipal_USR_Usuarios_1] FOREIGN KEY(idArbolPrincipal) REFERENCES[PRV_ArbolPrincipal_USR_Usuarios] (id) ON DELETE CASCADE " +
                                    " ALTER TABLE PRV_ArbolPrincipal_Imagenes_USR_Usuarios CHECK CONSTRAINT[FK_PRV_ArbolPrincipal_Imagenes_USR_Usuarios_PRV_ArbolPrincipal_USR_Usuarios_1] " +
                                " END ";


    }
}
