CREATE TABLE IF NOT EXISTS `users` (
 `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `email` VARCHAR(320) NOT NULL,
 `password_hash` VARCHAR(255) NOT NULL, `display_name` VARCHAR(120) NOT NULL DEFAULT '',
 `email_verified_at` VARCHAR(40) NULL, `created_at` VARCHAR(40) NOT NULL, `updated_at` VARCHAR(40) NOT NULL,
 PRIMARY KEY (`id`), UNIQUE KEY `users_email_unique` (`email`)
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE IF NOT EXISTS `user_tokens` (
 `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT, `user_id` BIGINT UNSIGNED NOT NULL,
 `token_hash` CHAR(64) NOT NULL, `token_type` VARCHAR(32) NOT NULL, `expires_at` VARCHAR(40) NOT NULL, `created_at` VARCHAR(40) NOT NULL,
 PRIMARY KEY (`id`), UNIQUE KEY `user_tokens_hash_unique` (`token_hash`), KEY `user_tokens_user_type_index` (`user_id`,`token_type`),
 CONSTRAINT `user_tokens_user_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
ALTER TABLE `events` ADD COLUMN `user_id` BIGINT UNSIGNED NULL AFTER `id`;
ALTER TABLE `events` ADD KEY `events_user_id_index` (`user_id`);
ALTER TABLE `events` ADD CONSTRAINT `events_user_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`) ON DELETE SET NULL;
