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

namespace Exferia_EntityFramework.Script_Actualizacion
{
    class Scripts_Version_1334
    {
        public static Version G_VRS_VERSION = new Version("1.3.3.4");
        public static long G_LNG_VERSION = 1334;
        public static int G_INT_TIPO = 0;
        public static string G_STR_SCRIPT =
                                     //AÑADIR campo convertirPDFA a la tabla GTD_PlantillasDocumentosCabecera
                                     "IF not exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='convertirPDFA' AND TABLE_NAME = 'GTD_PlantillasDocumentosCabecera' " +
                                      ") " +
                                    "BEGIN " +
                                        " ALTER TABLE [GTD_PlantillasDocumentosCabecera]ADD[convertirPDFA] bit NULL  " +
                                    "END " +
                                    //CREAR TABLA MYT_PartesLineas_Cobros
                                    " IF not exists " +
                                    " ( " +
                                        " SELECT * " +
                                        " FROM INFORMATION_SCHEMA.TABLES " +
                                        " WHERE TABLE_NAME = 'MYT_PartesLineas_Cobros' " +
                                    " ) " +
                                    " BEGIN " +
                                        " CREATE TABLE[dbo].[MYT_PartesLineas_Cobros] " +
                                        " ( " +
                                            " id[bigint] IDENTITY(1,1) NOT NULL, " +
                                            " idParte [bigint] NOT NULL, " +
                                            " fechaHora [datetime] NOT NULL, " +
                                            " metalico [decimal](20, 2) NULL, " +
                                            " talon [decimal](20, 2) NULL, " +
                                            " talon_numero [varchar](20) NULL, " +
                                            " talon_vencimiento [varchar](8) NULL, " +
                                            " idTipoPago [bigint] NULL, " +
                                            " total [decimal](20, 2) NOT NULL, " +
                                            " guid [varchar](50) NULL, " +
                                            " fechaBorrado [datetime] NULL, " +
                                        " CONSTRAINT[PK_MYT_PartesLineas_Cobros] 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] " +

                                        //Relaciones
                                        " ALTER TABLE[dbo].[MYT_PartesLineas_Cobros] WITH CHECK ADD CONSTRAINT[FK_MYT_PartesLineas_Cobros_MYT_Partes] FOREIGN KEY([idParte])REFERENCES[dbo].[MYT_Partes] ([id]) ON DELETE CASCADE " +
                                        " ALTER TABLE[dbo].[MYT_PartesLineas_Cobros] CHECK CONSTRAINT[FK_MYT_PartesLineas_Cobros_MYT_Partes] " +

                                        " ALTER TABLE[dbo].[MYT_PartesLineas_Cobros] WITH CHECK ADD CONSTRAINT[FK_MYT_PartesLineas_Cobros_MAE_TiposPagos] FOREIGN KEY([idTipoPago])REFERENCES[dbo].[MAE_TiposPagos] ([id]) " +
                                        " ALTER TABLE[dbo].[MYT_PartesLineas_Cobros] CHECK CONSTRAINT[FK_MYT_PartesLineas_Cobros_MAE_TiposPagos] " +

                                    " END ";

    }
}
