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

namespace Exferia_EntityFramework.Script_Actualizacion
{
    class Scripts_Version_1440
    {
        public static Version G_VRS_VERSION = new Version("1.4.4.0");
        public static long G_LNG_VERSION = 1437;
        public static int G_INT_TIPO = 0;
        public static string G_STR_SCRIPT =
            //creaccion de rutas--------------------------------
            $@"
            IF (exists 
		            (
                        SELECT * 
                        FROM INFORMATION_SCHEMA.TABLES
                        WHERE TABLE_NAME = 'INF_Rutas'
                    )
	            ) AND 
	            (not exists 
		            (
                        SELECT * 
                        FROM INF_Rutas
                        WHERE id = 15
                    )
	            )
            BEGIN
                  INSERT INTO INF_Rutas(id, codigo, descripcion, rutaFichero) VALUES (15, 15, 'Recepción de facturas electrónicas', 'C:\Pruebas\factura-e-recep')
            END
            IF (exists 
		            (
                        SELECT * 
                        FROM INFORMATION_SCHEMA.TABLES
                        WHERE TABLE_NAME = 'INF_Rutas'
                    )
	            ) AND 
	            (not exists 
		            (
                        SELECT * 
                        FROM INF_Rutas
                        WHERE id = 16
                    )
	            )
            BEGIN
                  INSERT INTO INF_Rutas(id, codigo, descripcion, rutaFichero) VALUES (16, 16, 'Emisión de facturas electrónicas', 'C:\Pruebas\factura-e-emi')
            END
            "+
            //CREAR TABLA GEN_Firmas_Electronicas---------------------------------------------------
            " IF not exists " +
            " ( " +
                " SELECT * " +
                " FROM INFORMATION_SCHEMA.TABLES " +
                " WHERE TABLE_NAME = 'GEN_Firmas_Electronicas' " +
            " ) " +
            " BEGIN " +
                    " CREATE TABLE[dbo].[GEN_Firmas_Electronicas]" +
                    " (" +
                        " [id][bigint] IDENTITY(1,1) NOT NULL," +
                        " [codigo] [varchar](10) NOT NULL," +
                        " [descripcion] [varchar](50) NOT NULL," +
                        " [fecha_fin] [datetime] NOT NULL," +
                        " [idEmpresa] [bigint] NULL," +
                        " [text_perm][text] NULL," +
                    " CONSTRAINT[PK_GEN_Firmas_Electronicas] PRIMARY KEY CLUSTERED" +
                    " (" +
                    " [id] ASC" +
                    " )WITH(PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON[PRIMARY]" +
                    " ) ON[PRIMARY]" +
                    /*
                    " ALTER TABLE[dbo].[GEN_Configuracion_Informes] WITH CHECK ADD CONSTRAINT[FK_GEN_Configuracion_Informes_GEN_EjerciciosActivos_Empresa] FOREIGN KEY([idEjercicio]) REFERENCES[dbo].[GEN_EjerciciosActivos_Empresa] ([id])" +
                    " ALTER TABLE[dbo].[GEN_Configuracion_Informes] CHECK CONSTRAINT[FK_GEN_Configuracion_Informes_GEN_EjerciciosActivos_Empresa]" +
                    */
            " END " 
            ;
    }

}
