diff --git a/db/versions/10862-navyHydrangea/00-alterAgencyTermConfig.sql b/db/versions/10862-navyHydrangea/00-alterAgencyTermConfig.sql new file mode 100644 index 000000000..3409b762e --- /dev/null +++ b/db/versions/10862-navyHydrangea/00-alterAgencyTermConfig.sql @@ -0,0 +1,3 @@ +USE vn; +ALTER TABLE vn.agencyTermConfig + ADD CONSTRAINT agencyTermConfig_expense_FK FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/10862-navyHydrangea/01-alterGastosResumen.sql b/db/versions/10862-navyHydrangea/00-alterGastosResumen.sql similarity index 60% rename from db/versions/10862-navyHydrangea/01-alterGastosResumen.sql rename to db/versions/10862-navyHydrangea/00-alterGastosResumen.sql index 7a90962c4..307b8f205 100644 --- a/db/versions/10862-navyHydrangea/01-alterGastosResumen.sql +++ b/db/versions/10862-navyHydrangea/00-alterGastosResumen.sql @@ -1,8 +1,11 @@ +USE vn; + ALTER TABLE vn2008.gastos_resumen MODIFY COLUMN Id_Gasto varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL; DELETE gr.* FROM vn2008.gastos_resumen gr LEFT JOIN vn.expense e ON gr.Id_Gasto = e.id - WHERE e.id IS NULL AND importe; + WHERE e.id IS NULL; ALTER TABLE vn2008.gastos_resumen - ADD CONSTRAINT gastos_resumen_expense_FKFOREIGN KEY (Id_Gasto) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE; + ADD CONSTRAINT gastos_resumen_expense_FK + FOREIGN KEY (Id_Gasto) REFERENCES vn.expense(id) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/db/versions/10862-navyHydrangea/00-alterInvoiceOutTaxConfig.sql b/db/versions/10862-navyHydrangea/00-alterInvoiceOutTaxConfig.sql new file mode 100644 index 000000000..fc5025c18 --- /dev/null +++ b/db/versions/10862-navyHydrangea/00-alterInvoiceOutTaxConfig.sql @@ -0,0 +1,5 @@ +USE vn; +ALTER TABLE vn.invoiceOutTaxConfig MODIFY COLUMN expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL NULL; + +ALTER TABLE vn.invoiceOutTaxConfig + ADD CONSTRAINT invoiceOutTaxConfig_expense_FK FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/10862-navyHydrangea/00-alterItemGroupToOffer.sql b/db/versions/10862-navyHydrangea/00-alterItemGroupToOffer.sql new file mode 100644 index 000000000..68611c13c --- /dev/null +++ b/db/versions/10862-navyHydrangea/00-alterItemGroupToOffer.sql @@ -0,0 +1,5 @@ +USE edi; +ALTER TABLE edi.item_groupToOffer MODIFY COLUMN expenseFk varchar(10) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT '7001000000' NULL; + +ALTER TABLE edi.item_groupToOffer + ADD CONSTRAINT item_groupToOffer_expense_FK FOREIGN KEY (expenseFk) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/10862-navyHydrangea/01-ventasContablesPk.sql b/db/versions/10862-navyHydrangea/01-ventasContablesPk.sql index 0ef62c405..3f8bf2c79 100644 --- a/db/versions/10862-navyHydrangea/01-ventasContablesPk.sql +++ b/db/versions/10862-navyHydrangea/01-ventasContablesPk.sql @@ -1,5 +1,14 @@ +USE vn; -- Eliminar la clave primaria actual ALTER TABLE bs.ventas_contables DROP PRIMARY KEY; -- Agregar la nueva clave primaria incluyendo el campo `gasto` ALTER TABLE bs.ventas_contables ADD PRIMARY KEY (`year`, `month`, `grupo`, `reino_id`, `tipo_id`, `empresa_id`, `gasto`); + +DELETE vc.* FROM bs.ventas_contables vc LEFT JOIN vn.expense e ON e.id = vc.gasto WHERE e.id IS NULL; + +ALTER TABLE bs.ventas_contables + MODIFY COLUMN gasto VARCHAR(10) + CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL; + +ALTER TABLE bs.ventas_contables ADD CONSTRAINT ventas_contables_expense_FK FOREIGN KEY (gasto) REFERENCES vn.expense(id) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/db/versions/10862-navyHydrangea/00-firstScript.sql b/db/versions/10862-navyHydrangea/02-updateExpenseRegularize.sql similarity index 71% rename from db/versions/10862-navyHydrangea/00-firstScript.sql rename to db/versions/10862-navyHydrangea/02-updateExpenseRegularize.sql index 2b79cf5db..7b7d1e197 100644 --- a/db/versions/10862-navyHydrangea/00-firstScript.sql +++ b/db/versions/10862-navyHydrangea/02-updateExpenseRegularize.sql @@ -6,6 +6,3 @@ UPDATE vn.expense UPDATE vn.expense SET id='7001090000' WHERE id='7001009000'; -UPDATE vn.balanceNestTree - SET expenseFk='7001090000' - WHERE expenseFk='7001009000'; diff --git a/db/versions/10862-navyHydrangea/02-updateExpense.sql b/db/versions/10862-navyHydrangea/03-updateExpense.sql similarity index 100% rename from db/versions/10862-navyHydrangea/02-updateExpense.sql rename to db/versions/10862-navyHydrangea/03-updateExpense.sql diff --git a/db/versions/10862-navyHydrangea/03-updateExpenseConflict.sql b/db/versions/10862-navyHydrangea/04-updateExpenseConflict.sql similarity index 100% rename from db/versions/10862-navyHydrangea/03-updateExpenseConflict.sql rename to db/versions/10862-navyHydrangea/04-updateExpenseConflict.sql diff --git a/db/versions/10862-navyHydrangea/06-updateItem.sql b/db/versions/10862-navyHydrangea/06-updateItem.sql deleted file mode 100644 index 8334232bf..000000000 --- a/db/versions/10862-navyHydrangea/06-updateItem.sql +++ /dev/null @@ -1,2 +0,0 @@ --- Actualizar los item.expenseFk de produccion propia --- Tot lo de producció propia porta el productor o *Polpiser o Santa Dorotea* diff --git a/db/versions/10862-navyHydrangea/09-updateVentasContables.sql b/db/versions/10862-navyHydrangea/09-updateVentasContables.sql deleted file mode 100644 index f59c3e140..000000000 --- a/db/versions/10862-navyHydrangea/09-updateVentasContables.sql +++ /dev/null @@ -1,37 +0,0 @@ -CALL bs.ventas_contables_add(2021, 1); -CALL bs.ventas_contables_add(2021, 2); -CALL bs.ventas_contables_add(2021, 3); -CALL bs.ventas_contables_add(2021, 4); -CALL bs.ventas_contables_add(2021, 5); -CALL bs.ventas_contables_add(2021, 6); -CALL bs.ventas_contables_add(2021, 7); -CALL bs.ventas_contables_add(2021, 8); -CALL bs.ventas_contables_add(2021, 9); -CALL bs.ventas_contables_add(2021, 10); -CALL bs.ventas_contables_add(2021, 11); -CALL bs.ventas_contables_add(2021, 12); -CALL bs.ventas_contables_add(2022, 1); -CALL bs.ventas_contables_add(2022, 2); -CALL bs.ventas_contables_add(2022, 3); -CALL bs.ventas_contables_add(2022, 4); -CALL bs.ventas_contables_add(2022, 5); -CALL bs.ventas_contables_add(2022, 6); -CALL bs.ventas_contables_add(2022, 7); -CALL bs.ventas_contables_add(2022, 8); -CALL bs.ventas_contables_add(2022, 9); -CALL bs.ventas_contables_add(2022, 10); -CALL bs.ventas_contables_add(2022, 11); -CALL bs.ventas_contables_add(2022, 12); -CALL bs.ventas_contables_add(2023, 1); -CALL bs.ventas_contables_add(2023, 2); -CALL bs.ventas_contables_add(2023, 3); -CALL bs.ventas_contables_add(2023, 4); -CALL bs.ventas_contables_add(2023, 5); -CALL bs.ventas_contables_add(2023, 6); -CALL bs.ventas_contables_add(2023, 7); -CALL bs.ventas_contables_add(2023, 8); -CALL bs.ventas_contables_add(2023, 9); -CALL bs.ventas_contables_add(2023, 10); -CALL bs.ventas_contables_add(2023, 11); -CALL bs.ventas_contables_add(2023, 12); -CALL bs.ventas_contables_add(2024, 1);