-- Alembic Revision: 54290c977da3

LOCK TABLES
    held_ticket_item_discounts WRITE,
    ticket_item_discounts WRITE;

UPDATE held_ticket_item_discounts SET value=0 WHERE value IS NULL;
ALTER TABLE held_ticket_item_discounts MODIFY value INT(11) NOT NULL;

ALTER TABLE held_ticket_item_discounts RENAME INDEX `fk-held_ticket_item_discounts-held_ticket_items` TO `fk_held_ticket_item_discounts_ticket_items`;
ALTER TABLE held_ticket_item_discounts
    DROP FOREIGN KEY `fk-held_ticket_item_discounts-held_ticket_items`,
    ADD CONSTRAINT `fk_held_ticket_item_discounts_ticket_items` FOREIGN KEY (`ticket_item_key`, `_cache_id`)
        REFERENCES `held_ticket_items` (`key`, _cache_id) ON DELETE cascade ON UPDATE cascade;


UPDATE ticket_item_discounts SET value=0 WHERE value IS NULL;
ALTER TABLE ticket_item_discounts MODIFY value INT(11) NOT NULL;

ALTER TABLE ticket_item_discounts RENAME INDEX `fk-ticket_item_discounts-ticket_items` TO `fk_ticket_item_discounts_ticket_items`;
ALTER TABLE ticket_item_discounts
    DROP FOREIGN KEY `fk-ticket_item_discounts-ticket_items`,
    ADD CONSTRAINT `fk_ticket_item_discounts_ticket_items` FOREIGN KEY (`ticket_item_key`, _cache_id)
        REFERENCES `ticket_items` (`key`, _cache_id) ON DELETE cascade ON UPDATE cascade;

UNLOCK TABLES;
