MT#22031 cosmetic up script changes for MariaDB compatibility

* "partition" is a reserved word in MariaDB and as such
      the existing column with name partition is escaped
      as `partition`
    * MariaDB is more restrictive to column alterations that have
      foreign keys in another tables and as such added
      constract drop/add wrapped into LOCK TABLES.
      LOCK TABLES is essential there as after DROP FOREIGN KEY
      up until the CONSTRANT is recreated again there is a chance
      to break the consistency with a wrong sql statement executed
      when the up script is being applied.

Change-Id: I4b08a1c5b2c5e1632e2683f62251fe3873ebc58e
changes/88/8088/8
Kirill Solomko 10 years ago
parent d7d4b1eed2
commit 8e03d7b475

@ -20,7 +20,7 @@ REPLACE INTO version (`table_name`, `table_version`) VALUES ('dialplan','2');
ALTER TABLE location ADD COLUMN server_id INT(11) DEFAULT 0 NOT NULL;
ALTER TABLE location ADD COLUMN connection_id INT(11) DEFAULT 0 NOT NULL;
ALTER TABLE location ADD COLUMN keepalive INT(11) DEFAULT 0 NOT NULL;
ALTER TABLE location ADD COLUMN partition INT(11) DEFAULT 0 NOT NULL;
ALTER TABLE location ADD COLUMN `partition` INT(11) DEFAULT 0 NOT NULL;
REPLACE INTO version (`table_name`, `table_version`) VALUES ('location','8');
-- table: presentity

@ -1,3 +1,13 @@
USE billing;
LOCK TABLES ncos_lnp_list WRITE, lnp_numbers WRITE, lnp_providers WRITE;
ALTER TABLE ncos_lnp_list DROP FOREIGN KEY `c_l_l_lnpproid_ref`;
ALTER TABLE lnp_numbers DROP FOREIGN KEY `l_n_lnpproid_ref`;
ALTER TABLE lnp_providers MODIFY id int(11) unsigned not null auto_increment;
ALTER TABLE ncos_lnp_list ADD CONSTRAINT `c_l_l_lnpproid_ref` FOREIGN KEY (`lnp_provider_id`) REFERENCES `lnp_providers` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
ALTER TABLE lnp_numbers ADD CONSTRAINT `l_n_lnpproid_ref` FOREIGN KEY (`lnp_provider_id`) REFERENCES `lnp_providers` (`id`) ON UPDATE CASCADE;
UNLOCK TABLES;

@ -9,7 +9,10 @@ WHERE
a.id < b.id
and (a.number = b.number and a.lnp_provider_id = b.lnp_provider_id);
ALTER TABLE lnp_numbers DROP FOREIGN KEY l_n_lnpproid_ref;
DROP INDEX l_n_lnpproid_ref ON lnp_numbers;
LOCK TABLES lnp_numbers WRITE;
ALTER TABLE lnp_numbers DROP FOREIGN KEY `l_n_lnpproid_ref`;
CREATE UNIQUE INDEX l_n_lnpproidnumber_idx ON lnp_numbers (lnp_provider_id,number);
ALTER TABLE lnp_numbers ADD CONSTRAINT l_n_lnpproid_ref FOREIGN KEY (lnp_provider_id) REFERENCES lnp_providers (id) ON DELETE RESTRICT ON UPDATE CASCADE;
UNLOCK TABLES;

Loading…
Cancel
Save