-- Alembic Revision: 2f2346b8b7cb

/*
  ***** SPECIAL ROLLOUT INSTRUCTIONS *****
  1. Create new table
  2. Insert rows into new table.
  3. Deploy code.
  4. Re-insert rows into new table again.
  5. Drop foreign key, index and column on items.
 */

create table `menu_combo_item_groups_menu_combo_items` (
  `_cache_id` varchar(128) collate utf8_bin not null,
  `menu_combo_item_group_id` varchar(64) collate utf8_bin not null,
  `menu_combo_item_id` varchar(64) collate utf8_bin not null,
  unique key `_cache_id` (`_cache_id`,`menu_combo_item_group_id`,`menu_combo_item_id`),
  key `idx_menu_combo_groups_to_menu_combo_items` (`_cache_id`,`menu_combo_item_id`),
  key `idx_menu_combo_items_to_menu_combo_groups` (`_cache_id`,`menu_combo_item_group_id`),
  constraint `fk_menu_combo_groups_to_menu_combo_items` foreign key (`_cache_id`, `menu_combo_item_id`)
    references `menu_combo_items` (`_cache_id`, `id`) on delete cascade on update cascade,
  constraint `fk_menu_combo_items_to_menu_combo_groups` foreign key (`_cache_id`, `menu_combo_item_group_id`)
    references `menu_combo_item_groups` (`_cache_id`, `id`) on delete cascade on update cascade
) engine=InnoDB default charset=utf8 collate=utf8_bin;


insert menu_combo_item_groups_menu_combo_items (_cache_id, menu_combo_item_group_id, menu_combo_item_id)
select _cache_id, menu_combo_item_group_id, id
  from menu_combo_items;
  
alter table menu_combo_items 
   drop foreign key fk_menu_combo_items_menu_combo_item_groups,
   drop key idx_menu_combo_item_menu_combo_item_group_id,
   drop column menu_combo_item_group_id,
   algorithm=inplace, lock=none;
   
  
