salix/db/versions/.archive/10610-goldenArborvitae/00-updateCompanyId.sql

105 lines
10 KiB
MySQL
Raw Permalink Normal View History

-- Place your SQL code here
ALTER TABLE hedera.`orderConfig` DROP FOREIGN KEY IF EXISTS `orderConfig_ibfk_2`;
ALTER TABLE vn.`project` DROP FOREIGN KEY IF EXISTS `project_FK_2`;
ALTER TABLE vn.`vehicle` DROP FOREIGN KEY IF EXISTS `vehicle_ibfk_1`;
ALTER TABLE vn.`routeConfig` DROP FOREIGN KEY IF EXISTS `routeConfig_FK`;
ALTER TABLE vn.`entry` DROP FOREIGN KEY IF EXISTS `entry_ibfk_7`;
ALTER TABLE vn.`payment` DROP FOREIGN KEY IF EXISTS `payment_ibfk_1`;
ALTER TABLE vn.`receipt` DROP FOREIGN KEY IF EXISTS `receipt_ibfk_1`;
ALTER TABLE vn.`invoiceIn` DROP FOREIGN KEY IF EXISTS `invoiceIn_ibfk_2`;
ALTER TABLE vn.`sinister` DROP FOREIGN KEY IF EXISTS `sinister_fk4`;
ALTER TABLE vn.`supplierExpense` DROP FOREIGN KEY IF EXISTS `pago_ibfk_1`;
ALTER TABLE vn.`ticket` DROP FOREIGN KEY IF EXISTS `ticket_ibfk_5`;
ALTER TABLE vn.`mandate` DROP FOREIGN KEY IF EXISTS `mandato_fgkey2`;
ALTER TABLE vn.`XDiario` DROP FOREIGN KEY IF EXISTS `XDiario_ibfk_1`;
ALTER TABLE vn.`dms` DROP FOREIGN KEY IF EXISTS `dms_companyFk`;
ALTER TABLE vn.`property` DROP FOREIGN KEY IF EXISTS `property_company`;
ALTER TABLE vn.`cmr` DROP FOREIGN KEY IF EXISTS `cmr_fk2`;
ALTER TABLE vn.`host` DROP FOREIGN KEY IF EXISTS `configHost_FK_3`;
ALTER TABLE vn.`clientRisk` DROP FOREIGN KEY IF EXISTS `clientRisk_ibfk_2`;
ALTER TABLE vn.`ppe` DROP FOREIGN KEY IF EXISTS `ppe_fk4`;
ALTER TABLE vn.`invoiceOut` DROP FOREIGN KEY IF EXISTS `invoiceOut_ibfk_1`;
ALTER TABLE vn.`dua` DROP FOREIGN KEY IF EXISTS `dua_fk4`;
ALTER TABLE vn.`clientSample` DROP FOREIGN KEY IF EXISTS `clientSample_ibfk_1`;
ALTER TABLE vn2008.`Saldos_Prevision` DROP FOREIGN KEY IF EXISTS `empresa_prevision`;
ALTER TABLE vn2008.`pago_sdc` DROP FOREIGN KEY IF EXISTS `empresa_sdc`;
ALTER TABLE vn2008.`Clientes_empresa` DROP FOREIGN KEY IF EXISTS `empresa_id`;
ALTER TABLE vn2008.`Bancos_poliza` DROP FOREIGN KEY IF EXISTS `Id_Poliza_Empresa`;
ALTER TABLE vn2008.`Permisos` DROP FOREIGN KEY IF EXISTS `Permisos_ibfk_1`;
ALTER TABLE vn2008.`albaran` DROP FOREIGN KEY IF EXISTS `fk_albaran_empresa1`;
ALTER TABLE vn2008.`Remesas` DROP FOREIGN KEY IF EXISTS `Remesas_ibfk_1`;
ALTER TABLE vn2008.`Enlaces Facturas__` DROP FOREIGN KEY IF EXISTS `Enlaces@0020Facturas_ibfk_1`;
ALTER TABLE bs.`sale` DROP FOREIGN KEY IF EXISTS `sale_FK_2`;
ALTER TABLE vn.`farming` DROP FOREIGN KEY IF EXISTS `farming_Fk_1`;
ALTER TABLE vn.companyI18n DROP FOREIGN KEY IF EXISTS companyI18n_FK;
ALTER TABLE vn.company MODIFY COLUMN id INT UNSIGNED NOT NULL;
ALTER TABLE hedera.`orderConfig` MODIFY COLUMN defaultCompanyFk INT UNSIGNED DEFAULT NULL;
ALTER TABLE vn.`project` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`vehicle` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`routeConfig` MODIFY COLUMN defaultCompanyFk INT UNSIGNED DEFAULT 442;
ALTER TABLE vn.`entry` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`payment` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`receipt` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`invoiceIn` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`sinister` MODIFY COLUMN companyFk INT UNSIGNED NOT NULL ;
ALTER TABLE vn.`supplierExpense` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`ticket` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`mandate` MODIFY COLUMN companyFk INT UNSIGNED NOT NULL ;
ALTER TABLE vn.`XDiario` MODIFY COLUMN empresa_id INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`dms` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`property` MODIFY COLUMN companyFk INT UNSIGNED NOT NULL ;
ALTER TABLE vn.`cmr` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT NULL;
ALTER TABLE vn.`host` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442;
ALTER TABLE vn.`clientRisk` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 0 NOT NULL ;
ALTER TABLE vn.`ppe` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
-- ALTER TABLE vn.`invoiceOut` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`dua` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`clientSample` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT NULL;
ALTER TABLE vn2008.`Saldos_Prevision` MODIFY COLUMN empresa_id INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn2008.`pago_sdc` MODIFY COLUMN empresa_id INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn2008.`Clientes_empresa` MODIFY COLUMN empresa_id INT UNSIGNED NOT NULL ;
ALTER TABLE vn2008.`Bancos_poliza` MODIFY COLUMN empresa_id INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn2008.`Permisos` MODIFY COLUMN empresa_id INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn2008.`albaran` MODIFY COLUMN empresa_id INT UNSIGNED NOT NULL ;
ALTER TABLE vn2008.`Remesas` MODIFY COLUMN empresa_id INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn2008.`Enlaces Facturas__` MODIFY COLUMN empresa_id INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE bs.`sale` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.`farming` MODIFY COLUMN companyFk INT UNSIGNED DEFAULT 442 NOT NULL ;
ALTER TABLE vn.companyI18n MODIFY COLUMN companyFk INT UNSIGNED NOT NULL;
ALTER TABLE hedera.`orderConfig` ADD CONSTRAINT `orderConfigCompany_Fk` FOREIGN KEY IF NOT EXISTS (defaultCompanyFk) REFERENCES vn.company(id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`project` ADD CONSTRAINT `projectCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE vn.`vehicle` ADD CONSTRAINT `vehicleCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`routeConfig` ADD CONSTRAINT `routeConfigCompany_Fk` FOREIGN KEY IF NOT EXISTS (defaultCompanyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE vn.`entry` ADD CONSTRAINT `entryCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`payment` ADD CONSTRAINT `paymentCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`receipt` ADD CONSTRAINT `receiptCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`invoiceIn` ADD CONSTRAINT `invoiceInCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`sinister` ADD CONSTRAINT `sinisterCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE vn.`supplierExpense` ADD CONSTRAINT `supplierExpenseCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`ticket` ADD CONSTRAINT `ticketCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`mandate` ADD CONSTRAINT `mandateCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE NO ACTION ON UPDATE CASCADE;
ALTER TABLE vn.`XDiario` ADD CONSTRAINT `XDiarioCompany_Fk` FOREIGN KEY IF NOT EXISTS (empresa_id) REFERENCES vn.company (id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE vn.`dms` ADD CONSTRAINT `dmsCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`property` ADD CONSTRAINT `propertyCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`cmr` ADD CONSTRAINT `cmrCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE SET NULL ON UPDATE CASCADE;
ALTER TABLE vn.`host` ADD CONSTRAINT `hostCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`clientRisk` ADD CONSTRAINT `clientRiskCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE vn.`ppe` ADD CONSTRAINT `ppeCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
-- ALTER TABLE vn.`invoiceOut` ADD CONSTRAINT `invoiceOutCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`dua` ADD CONSTRAINT `duaCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn.`clientSample` ADD CONSTRAINT `clientSampleCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn2008.`Saldos_Prevision` ADD CONSTRAINT `Saldos_PrevisionCompany_Fk` FOREIGN KEY IF NOT EXISTS (empresa_id) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn2008.`pago_sdc` ADD CONSTRAINT `pago_sdcCompany_Fk` FOREIGN KEY IF NOT EXISTS (empresa_id) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn2008.`Clientes_empresa` ADD CONSTRAINT `Clientes_empresaCompany_Fk` FOREIGN KEY IF NOT EXISTS (empresa_id) REFERENCES vn.company (id) ON DELETE NO ACTION ON UPDATE RESTRICT;
ALTER TABLE vn2008.`Bancos_poliza` ADD CONSTRAINT `Bancos_polizaCompany_Fk` FOREIGN KEY IF NOT EXISTS (empresa_id) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn2008.`Permisos` ADD CONSTRAINT `PermisosCompany_Fk` FOREIGN KEY IF NOT EXISTS (empresa_id) REFERENCES vn.company (id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE vn2008.`albaran` ADD CONSTRAINT `albaranCompany_Fk` FOREIGN KEY IF NOT EXISTS (empresa_id) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn2008.`Remesas` ADD CONSTRAINT `RemesasCompany_Fk` FOREIGN KEY IF NOT EXISTS (empresa_id) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE vn2008.`Enlaces Facturas__` ADD CONSTRAINT `EnlacesFacturas__Company_Fk` FOREIGN KEY IF NOT EXISTS (empresa_id) REFERENCES vn.company (id) ON DELETE RESTRICT ON UPDATE CASCADE;
ALTER TABLE bs.`sale` ADD CONSTRAINT `saleCompany_Fk` FOREIGN KEY IF NOT EXISTS (companyFk) REFERENCES vn.company (id) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE vn.`farming` ADD CONSTRAINT `farmingCompany_Fk` FOREIGN KEY IF NOT EXISTS(companyFk) REFERENCES vn.company(id) ON DELETE RESTRICT ON UPDATE RESTRICT;
ALTER TABLE vn.`companyI18n` ADD CONSTRAINT `companyI18nCompany_Fk` FOREIGN KEY IF NOT EXISTS(companyFk) REFERENCES vn.company(id) ON DELETE RESTRICT ON UPDATE CASCADE;