2024-02-15 13:21:49 +00:00
|
|
|
USE vn;
|
2024-02-02 07:05:17 +00:00
|
|
|
-- 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`);
|
2024-02-15 13:21:49 +00:00
|
|
|
|
|
|
|
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;
|