diff --git a/install/sqls/00034-polls.sql b/install/sqls/00034-polls.sql new file mode 100644 index 00000000..8122549b --- /dev/null +++ b/install/sqls/00034-polls.sql @@ -0,0 +1,32 @@ +CREATE TABLE IF NOT EXISTS `polls` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `owner` bigint unsigned NOT NULL, + `title` text NOT NULL, + `allows_multiple` bit(1) NOT NULL DEFAULT b'0', + `is_anonymous` bit(1) NOT NULL DEFAULT b'0', + `can_revote` bit(1) NOT NULL DEFAULT b'0', + `until` bigint unsigned DEFAULT NULL, + `ended` bit(1) NOT NULL DEFAULT b'0', + `deleted` bit(1) NOT NULL DEFAULT b'0', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; + +CREATE TABLE IF NOT EXISTS `poll_options` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `poll` bigint unsigned NOT NULL, + `name` varchar(512) NOT NULL, + PRIMARY KEY (`id`), + KEY `poll` (`poll`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci; + +CREATE TABLE IF NOT EXISTS `poll_votes` ( + `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `user` bigint unsigned NOT NULL, + `poll` bigint unsigned NOT NULL, + `option` bigint unsigned NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `user_option` (`user`,`option`), + KEY `option` (`option`), + KEY `poll` (`poll`), + KEY `user_poll` (`user`,`poll`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_520_ci;