ALTER TABLE `events`
  ADD COLUMN `location_type` VARCHAR(24) NOT NULL DEFAULT 'in_person' AFTER `time`,
  ADD COLUMN `venue_name` VARCHAR(191) NULL AFTER `location_type`,
  ADD COLUMN `address` VARCHAR(255) NULL AFTER `venue_name`,
  ADD COLUMN `postal_code` VARCHAR(12) NULL AFTER `address`,
  ADD COLUMN `city` VARCHAR(120) NULL AFTER `postal_code`,
  ADD COLUMN `department` VARCHAR(120) NULL AFTER `city`,
  ADD COLUMN `online_url` VARCHAR(2048) NULL AFTER `department`,
  ADD COLUMN `latitude` DECIMAL(10,7) NULL AFTER `online_url`,
  ADD COLUMN `longitude` DECIMAL(10,7) NULL AFTER `latitude`,
  ADD KEY `events_location_type_index` (`location_type`),
  ADD KEY `events_department_index` (`department`),
  ADD KEY `events_city_index` (`city`);

ALTER TABLE `users`
  ADD COLUMN `favorite_location_type` VARCHAR(24) NULL AFTER `display_name`,
  ADD COLUMN `favorite_venue_name` VARCHAR(191) NULL AFTER `favorite_location_type`,
  ADD COLUMN `favorite_address` VARCHAR(255) NULL AFTER `favorite_venue_name`,
  ADD COLUMN `favorite_postal_code` VARCHAR(12) NULL AFTER `favorite_address`,
  ADD COLUMN `favorite_city` VARCHAR(120) NULL AFTER `favorite_postal_code`,
  ADD COLUMN `favorite_department` VARCHAR(120) NULL AFTER `favorite_city`;

UPDATE `events` SET `location_type`='online' WHERE LOWER(`location`) LIKE '%en ligne%' OR LOWER(`location`) LIKE '%visio%';
