[
  {
    "type": "alter_table",
    "description": "Drop FK on staff_chat_channel_members before modifying index",
    "database": "{{store}}",
    "check_query": "SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'staff_chat_channel_members' AND CONSTRAINT_NAME = 'fk_staff_chat_member_channel'",
    "check_value": "1",
    "sql": "ALTER TABLE `staff_chat_channel_members` DROP FOREIGN KEY `fk_staff_chat_member_channel`"
  },
  {
    "type": "alter_table",
    "description": "Rename employeeId to userId in staff_chat_channel_members",
    "database": "{{store}}",
    "check_query": "SHOW COLUMNS FROM staff_chat_channel_members LIKE 'userId'",
    "sql": "ALTER TABLE `staff_chat_channel_members` DROP INDEX `uk_channel_employee`, DROP INDEX `idx_employeeId`, CHANGE COLUMN `employeeId` `userId` int(10) unsigned NOT NULL COMMENT 'kiosk_users.users.id', ADD UNIQUE KEY `uk_channel_user` (`channelId`, `userId`), ADD INDEX `idx_userId` (`userId`)"
  },
  {
    "type": "alter_table",
    "description": "Re-add FK on staff_chat_channel_members",
    "database": "{{store}}",
    "check_query": "SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'staff_chat_channel_members' AND CONSTRAINT_NAME = 'fk_staff_chat_member_channel'",
    "check_value": "0",
    "sql": "ALTER TABLE `staff_chat_channel_members` ADD CONSTRAINT `fk_staff_chat_member_channel` FOREIGN KEY (`channelId`) REFERENCES `staff_chat_channels` (`id`) ON DELETE CASCADE"
  },
  {
    "type": "alter_table",
    "description": "Drop FK on staff_chat_read_receipts before modifying index",
    "database": "{{store}}",
    "check_query": "SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'staff_chat_read_receipts' AND CONSTRAINT_NAME = 'fk_staff_chat_read_channel'",
    "check_value": "1",
    "sql": "ALTER TABLE `staff_chat_read_receipts` DROP FOREIGN KEY `fk_staff_chat_read_channel`"
  },
  {
    "type": "alter_table",
    "description": "Rename employeeId to userId in staff_chat_read_receipts",
    "database": "{{store}}",
    "check_query": "SHOW COLUMNS FROM staff_chat_read_receipts LIKE 'userId'",
    "sql": "ALTER TABLE `staff_chat_read_receipts` DROP INDEX `uk_channel_employee`, DROP INDEX `idx_employeeId`, CHANGE COLUMN `employeeId` `userId` int(10) unsigned NOT NULL COMMENT 'kiosk_users.users.id', ADD UNIQUE KEY `uk_channel_user` (`channelId`, `userId`), ADD INDEX `idx_userId` (`userId`)"
  },
  {
    "type": "alter_table",
    "description": "Re-add FK on staff_chat_read_receipts",
    "database": "{{store}}",
    "check_query": "SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'staff_chat_read_receipts' AND CONSTRAINT_NAME = 'fk_staff_chat_read_channel'",
    "check_value": "0",
    "sql": "ALTER TABLE `staff_chat_read_receipts` ADD CONSTRAINT `fk_staff_chat_read_channel` FOREIGN KEY (`channelId`) REFERENCES `staff_chat_channels` (`id`) ON DELETE CASCADE"
  },
  {
    "type": "alter_table",
    "description": "Drop FK on staff_chat_mentions before modifying index",
    "database": "{{store}}",
    "check_query": "SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'staff_chat_mentions' AND CONSTRAINT_NAME = 'fk_staff_chat_mention_message'",
    "check_value": "1",
    "sql": "ALTER TABLE `staff_chat_mentions` DROP FOREIGN KEY `fk_staff_chat_mention_message`"
  },
  {
    "type": "alter_table",
    "description": "Rename mentionedEmployeeId to mentionedUserId in staff_chat_mentions",
    "database": "{{store}}",
    "check_query": "SHOW COLUMNS FROM staff_chat_mentions LIKE 'mentionedUserId'",
    "sql": "ALTER TABLE `staff_chat_mentions` DROP INDEX `uk_message_employee`, DROP INDEX `idx_mentionedEmployeeId`, CHANGE COLUMN `mentionedEmployeeId` `mentionedUserId` int(10) unsigned NOT NULL COMMENT 'kiosk_users.users.id', ADD UNIQUE KEY `uk_message_user` (`messageId`, `mentionedUserId`), ADD INDEX `idx_mentionedUserId` (`mentionedUserId`)"
  },
  {
    "type": "alter_table",
    "description": "Re-add FK on staff_chat_mentions",
    "database": "{{store}}",
    "check_query": "SELECT COUNT(*) FROM information_schema.TABLE_CONSTRAINTS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME = 'staff_chat_mentions' AND CONSTRAINT_NAME = 'fk_staff_chat_mention_message'",
    "check_value": "0",
    "sql": "ALTER TABLE `staff_chat_mentions` ADD CONSTRAINT `fk_staff_chat_mention_message` FOREIGN KEY (`messageId`) REFERENCES `staff_chat_messages` (`id`) ON DELETE CASCADE"
  }
]
