Skip to content

Instantly share code, notes, and snippets.

@pushcx
Last active February 12, 2026 17:47
Show Gist options
  • Select an option

  • Save pushcx/bbdbf98ab6734656f5cad828c8c6cfca to your computer and use it in GitHub Desktop.

Select an option

Save pushcx/bbdbf98ab6734656f5cad828c8c6cfca to your computer and use it in GitHub Desktop.
structure.sql for dzwdz
/*M!999999\- enable the sandbox mode */
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*M!100616 SET @OLD_NOTE_VERBOSITY=@@NOTE_VERBOSITY, NOTE_VERBOSITY=0 */;
DROP TABLE IF EXISTS `action_mailbox_inbound_emails`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `action_mailbox_inbound_emails` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`status` int(11) NOT NULL DEFAULT 0,
`message_id` varchar(255) NOT NULL,
`message_checksum` varchar(255) NOT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_action_mailbox_inbound_emails_uniqueness` (`message_id`,`message_checksum`)
) ENGINE=InnoDB AUTO_INCREMENT=91363 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `active_storage_attachments`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `active_storage_attachments` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`record_type` varchar(255) NOT NULL,
`record_id` bigint(20) NOT NULL,
`blob_id` bigint(20) NOT NULL,
`created_at` datetime(6) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_active_storage_attachments_uniqueness` (`record_type`,`record_id`,`name`,`blob_id`),
KEY `index_active_storage_attachments_on_blob_id` (`blob_id`),
CONSTRAINT `fk_rails_c3b3935057` FOREIGN KEY (`blob_id`) REFERENCES `active_storage_blobs` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=91363 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `active_storage_blobs`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `active_storage_blobs` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`key` varchar(255) NOT NULL,
`filename` varchar(255) NOT NULL,
`content_type` varchar(255) DEFAULT NULL,
`metadata` text DEFAULT NULL,
`service_name` varchar(255) NOT NULL,
`byte_size` bigint(20) NOT NULL,
`checksum` varchar(255) DEFAULT NULL,
`created_at` datetime(6) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_active_storage_blobs_on_key` (`key`)
) ENGINE=InnoDB AUTO_INCREMENT=91395 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `active_storage_variant_records`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `active_storage_variant_records` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`blob_id` bigint(20) NOT NULL,
`variation_digest` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_active_storage_variant_records_uniqueness` (`blob_id`,`variation_digest`),
CONSTRAINT `fk_rails_993965df05` FOREIGN KEY (`blob_id`) REFERENCES `active_storage_blobs` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `ar_internal_metadata`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `ar_internal_metadata` (
`key` varchar(255) NOT NULL,
`value` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `categories`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `categories` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`category` varchar(25) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_categories_on_category` (`category`),
UNIQUE KEY `index_categories_on_token` (`token`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `comment_stats`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `comment_stats` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`date` date NOT NULL,
`average` int(11) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_comment_stats_on_date` (`date`)
) ENGINE=InnoDB AUTO_INCREMENT=4804 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `comments`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `comments` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime DEFAULT NULL,
`short_id` varchar(10) NOT NULL DEFAULT '',
`story_id` bigint(20) unsigned NOT NULL,
`confidence_order` binary(3) NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`parent_comment_id` bigint(20) unsigned DEFAULT NULL,
`thread_id` bigint(20) unsigned DEFAULT NULL,
`comment` mediumtext NOT NULL,
`score` int(11) NOT NULL DEFAULT 1,
`flags` int(10) unsigned NOT NULL DEFAULT 0,
`confidence` decimal(20,19) NOT NULL DEFAULT 0.0000000000000000000,
`markeddown_comment` mediumtext DEFAULT NULL,
`is_deleted` tinyint(1) NOT NULL DEFAULT 0,
`is_moderated` tinyint(1) NOT NULL DEFAULT 0,
`is_from_email` tinyint(1) NOT NULL DEFAULT 0,
`hat_id` bigint(20) unsigned DEFAULT NULL,
`depth` int(11) NOT NULL DEFAULT 0,
`reply_count` int(11) NOT NULL DEFAULT 0,
`last_reply_at` datetime(6) DEFAULT NULL,
`last_edited_at` datetime(6) NOT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `short_id` (`short_id`),
UNIQUE KEY `index_comments_on_token` (`token`),
KEY `thread_id` (`thread_id`),
KEY `story_id_short_id` (`story_id`,`short_id`),
KEY `confidence_idx` (`confidence`),
KEY `index_comments_on_user_id` (`user_id`),
KEY `comments_hat_id_fk` (`hat_id`),
KEY `comments_parent_comment_id_fk` (`parent_comment_id`),
KEY `index_comments_on_score` (`score`),
FULLTEXT KEY `index_comments_on_comment` (`comment`),
CONSTRAINT `comments_hat_id_fk` FOREIGN KEY (`hat_id`) REFERENCES `hats` (`id`),
CONSTRAINT `comments_parent_comment_id_fk` FOREIGN KEY (`parent_comment_id`) REFERENCES `comments` (`id`),
CONSTRAINT `comments_story_id_fk` FOREIGN KEY (`story_id`) REFERENCES `stories` (`id`),
CONSTRAINT `comments_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=651422 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `domains`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `domains` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`domain` varchar(255) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`banned_at` datetime DEFAULT NULL,
`banned_by_user_id` bigint(20) unsigned DEFAULT NULL,
`banned_reason` varchar(200) DEFAULT NULL,
`selector` varchar(255) DEFAULT NULL,
`replacement` varchar(255) DEFAULT NULL,
`stories_count` int(11) NOT NULL DEFAULT 0,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_domains_on_domain` (`domain`),
UNIQUE KEY `index_domains_on_token` (`token`),
KEY `index_domains_on_banned_by_user_id` (`banned_by_user_id`),
CONSTRAINT `fk_rails_c15837f026` FOREIGN KEY (`banned_by_user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=33291 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `hat_requests`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `hat_requests` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`hat` varchar(255) NOT NULL,
`link` varchar(255) NOT NULL,
`comment` text NOT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_hat_requests_on_token` (`token`),
KEY `hat_requests_user_id_fk` (`user_id`),
CONSTRAINT `hat_requests_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=101 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `hats`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `hats` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime DEFAULT NULL,
`updated_at` datetime DEFAULT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`granted_by_user_id` bigint(20) unsigned NOT NULL,
`hat` varchar(255) NOT NULL,
`link` varchar(255) DEFAULT NULL,
`modlog_use` tinyint(1) NOT NULL DEFAULT 0,
`doffed_at` datetime DEFAULT NULL,
`short_id` varchar(10) NOT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_hats_on_token` (`token`),
KEY `hats_granted_by_user_id_fk` (`granted_by_user_id`),
KEY `hats_user_id_fk` (`user_id`),
CONSTRAINT `hats_granted_by_user_id_fk` FOREIGN KEY (`granted_by_user_id`) REFERENCES `users` (`id`),
CONSTRAINT `hats_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=282 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `hidden_stories`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `hidden_stories` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) unsigned NOT NULL,
`story_id` bigint(20) unsigned NOT NULL,
`created_at` datetime(6) DEFAULT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_hidden_stories_on_user_id_and_story_id` (`user_id`,`story_id`),
UNIQUE KEY `index_hidden_stories_on_token` (`token`),
KEY `hidden_stories_story_id_fk` (`story_id`),
CONSTRAINT `hidden_stories_story_id_fk` FOREIGN KEY (`story_id`) REFERENCES `stories` (`id`),
CONSTRAINT `hidden_stories_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=251476 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `invitation_requests`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invitation_requests` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`code` varchar(255) DEFAULT NULL,
`is_verified` tinyint(1) NOT NULL DEFAULT 0,
`email` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`memo` tinytext DEFAULT NULL,
`ip_address` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_invitation_requests_on_token` (`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `invitations`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `invitations` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) unsigned NOT NULL,
`email` varchar(255) DEFAULT NULL,
`code` varchar(255) DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`memo` text DEFAULT NULL,
`used_at` datetime DEFAULT NULL,
`new_user_id` bigint(20) unsigned DEFAULT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_invitations_on_token` (`token`),
KEY `invitations_new_user_id_fk` (`new_user_id`),
KEY `invitations_user_id_fk` (`user_id`),
CONSTRAINT `invitations_new_user_id_fk` FOREIGN KEY (`new_user_id`) REFERENCES `users` (`id`),
CONSTRAINT `invitations_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=12990 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `keystores`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `keystores` (
`key` varchar(50) NOT NULL DEFAULT '',
`value` bigint(20) DEFAULT NULL,
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`),
UNIQUE KEY `key` (`key`)
) ENGINE=InnoDB AUTO_INCREMENT=4249751 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `links`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `links` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`url` varchar(250) NOT NULL,
`normalized_url` varchar(255) NOT NULL,
`title` varchar(255) DEFAULT NULL,
`from_story_id` bigint(20) unsigned DEFAULT NULL,
`from_comment_id` bigint(20) unsigned DEFAULT NULL,
`to_story_id` bigint(20) unsigned DEFAULT NULL,
`to_comment_id` bigint(20) unsigned DEFAULT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_links_on_url_and_from_story_id_and_from_comment_id` (`url`,`from_story_id`,`from_comment_id`),
UNIQUE KEY `idx_links_on_to_comment_id_and_from_story_id_and_from_comment_id` (`to_comment_id`,`from_story_id`,`from_comment_id`),
UNIQUE KEY `index_links_on_to_story_id_and_from_story_id_and_from_comment_id` (`to_story_id`,`from_story_id`,`from_comment_id`),
KEY `index_links_on_normalized_url` (`normalized_url`),
KEY `index_links_on_from_story_id` (`from_story_id`),
KEY `index_links_on_from_comment_id` (`from_comment_id`),
CONSTRAINT `fk_rails_51de50cb3b` FOREIGN KEY (`from_comment_id`) REFERENCES `comments` (`id`),
CONSTRAINT `fk_rails_ac0932f49b` FOREIGN KEY (`to_comment_id`) REFERENCES `comments` (`id`),
CONSTRAINT `fk_rails_d7bbd2b475` FOREIGN KEY (`from_story_id`) REFERENCES `stories` (`id`),
CONSTRAINT `fk_rails_f04e4c6073` FOREIGN KEY (`to_story_id`) REFERENCES `stories` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=287727 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mastodon_apps`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mastodon_apps` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`client_id` varchar(255) NOT NULL,
`client_secret` varchar(255) NOT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_mastodon_apps_on_name` (`name`)
) ENGINE=InnoDB AUTO_INCREMENT=225 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `messages`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `messages` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime DEFAULT NULL,
`author_user_id` bigint(20) unsigned DEFAULT NULL,
`recipient_user_id` bigint(20) unsigned NOT NULL,
`subject` varchar(100) DEFAULT NULL,
`body` mediumtext DEFAULT NULL,
`short_id` varchar(30) NOT NULL DEFAULT '',
`deleted_by_author` tinyint(1) NOT NULL DEFAULT 0,
`deleted_by_recipient` tinyint(1) NOT NULL DEFAULT 0,
`hat_id` bigint(20) unsigned DEFAULT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_messages_on_token` (`token`),
UNIQUE KEY `random_hash` (`short_id`),
KEY `index_messages_on_hat_id` (`hat_id`),
KEY `messages_recipient_user_id_fk` (`recipient_user_id`),
KEY `index_messages_on_author_user_id` (`author_user_id`),
CONSTRAINT `fk_rails_013215d0ae` FOREIGN KEY (`author_user_id`) REFERENCES `users` (`id`),
CONSTRAINT `messages_hat_id_fk` FOREIGN KEY (`hat_id`) REFERENCES `hats` (`id`),
CONSTRAINT `messages_recipient_user_id_fk` FOREIGN KEY (`recipient_user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=20405 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mod_activities`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mod_activities` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`item_type` varchar(255) NOT NULL,
`item_id` bigint(20) unsigned NOT NULL,
`token` varchar(255) NOT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_mod_activities_on_item_type_and_item_id` (`item_type`,`item_id`),
UNIQUE KEY `index_mod_activities_on_token` (`token`)
) ENGINE=InnoDB AUTO_INCREMENT=22177 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mod_mail_messages`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mod_mail_messages` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`mod_mail_id` bigint(20) NOT NULL,
`message` mediumtext NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) NOT NULL,
PRIMARY KEY (`id`),
KEY `index_mod_mail_messages_on_mod_mail_id` (`mod_mail_id`),
KEY `fk_rails_40fa20cab5` (`user_id`),
CONSTRAINT `fk_rails_40fa20cab5` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
CONSTRAINT `fk_rails_58a2afacf2` FOREIGN KEY (`mod_mail_id`) REFERENCES `mod_mails` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mod_mail_recipients`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mod_mail_recipients` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`mod_mail_id` bigint(20) NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) NOT NULL,
PRIMARY KEY (`id`),
KEY `index_mod_mail_recipients_on_mod_mail_id` (`mod_mail_id`),
KEY `fk_rails_7a6d5232be` (`user_id`),
CONSTRAINT `fk_rails_4b3ed28906` FOREIGN KEY (`mod_mail_id`) REFERENCES `mod_mails` (`id`),
CONSTRAINT `fk_rails_7a6d5232be` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mod_mail_references`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mod_mail_references` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`mod_mail_id` bigint(20) NOT NULL,
`reference_type` varchar(255) NOT NULL,
`reference_id` bigint(20) NOT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) NOT NULL,
PRIMARY KEY (`id`),
KEY `index_mod_mail_references_on_mod_mail_id` (`mod_mail_id`),
KEY `index_mod_mail_references_on_reference` (`reference_type`,`reference_id`),
CONSTRAINT `fk_rails_2508982161` FOREIGN KEY (`mod_mail_id`) REFERENCES `mod_mails` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mod_mails`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mod_mails` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`subject` varchar(255) NOT NULL,
`remind_mods_at` datetime(6) DEFAULT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) NOT NULL,
`short_id` varchar(10) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_mod_mails_on_short_id` (`short_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `mod_notes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `mod_notes` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`moderator_user_id` bigint(20) unsigned NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`note` text NOT NULL,
`markeddown_note` text NOT NULL,
`created_at` datetime NOT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_mod_notes_on_token` (`token`),
KEY `index_mod_notes_on_id_and_user_id` (`id`,`user_id`),
KEY `mod_notes_moderator_user_id_fk` (`moderator_user_id`),
KEY `mod_notes_user_id_fk` (`user_id`),
CONSTRAINT `mod_notes_moderator_user_id_fk` FOREIGN KEY (`moderator_user_id`) REFERENCES `users` (`id`),
CONSTRAINT `mod_notes_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=8761 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `moderations`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `moderations` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`moderator_user_id` bigint(20) unsigned DEFAULT NULL,
`story_id` bigint(20) unsigned DEFAULT NULL,
`comment_id` bigint(20) unsigned DEFAULT NULL,
`user_id` bigint(20) unsigned DEFAULT NULL,
`action` longtext NOT NULL,
`reason` mediumtext DEFAULT NULL,
`is_from_suggestions` tinyint(1) NOT NULL DEFAULT 0,
`tag_id` bigint(20) unsigned DEFAULT NULL,
`domain_id` bigint(20) DEFAULT NULL,
`category_id` bigint(20) DEFAULT NULL,
`origin_id` bigint(20) DEFAULT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_moderations_on_token` (`token`),
KEY `index_moderations_on_created_at` (`created_at`),
KEY `moderations_comment_id_fk` (`comment_id`),
KEY `moderations_moderator_user_id_fk` (`moderator_user_id`),
KEY `moderations_story_id_fk` (`story_id`),
KEY `moderations_tag_id_fk` (`tag_id`),
KEY `index_moderations_on_user_id` (`user_id`),
KEY `index_moderations_on_domain_id` (`domain_id`),
KEY `index_moderations_on_category_id` (`category_id`),
KEY `index_moderations_on_origin_id` (`origin_id`),
CONSTRAINT `fk_rails_a286a4afe4` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`),
CONSTRAINT `fk_rails_ac858bba09` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`),
CONSTRAINT `fk_rails_b95b064e59` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`),
CONSTRAINT `fk_rails_babb42ccfe` FOREIGN KEY (`origin_id`) REFERENCES `origins` (`id`),
CONSTRAINT `moderations_comment_id_fk` FOREIGN KEY (`comment_id`) REFERENCES `comments` (`id`),
CONSTRAINT `moderations_moderator_user_id_fk` FOREIGN KEY (`moderator_user_id`) REFERENCES `users` (`id`),
CONSTRAINT `moderations_story_id_fk` FOREIGN KEY (`story_id`) REFERENCES `stories` (`id`),
CONSTRAINT `moderations_tag_id_fk` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13648 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `notifications`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `notifications` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) unsigned NOT NULL,
`notifiable_type` varchar(255) NOT NULL,
`notifiable_id` bigint(20) unsigned NOT NULL,
`read_at` datetime(6) DEFAULT NULL,
`token` varchar(255) NOT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_on_user_id_notifiable_type_notifiable_id_ffac34041e` (`user_id`,`notifiable_type`,`notifiable_id`),
UNIQUE KEY `index_notifications_on_token` (`token`),
KEY `index_notifications_on_notifiable` (`notifiable_type`,`notifiable_id`),
CONSTRAINT `fk_rails_b080fb4855` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=473896 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `origins`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `origins` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`domain_id` bigint(20) NOT NULL,
`identifier` varchar(255) NOT NULL,
`stories_count` int(11) NOT NULL DEFAULT 0,
`banned_at` datetime(6) DEFAULT NULL,
`banned_by_user_id` bigint(20) unsigned DEFAULT NULL,
`banned_reason` varchar(200) DEFAULT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) NOT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_origins_on_identifier` (`identifier`),
UNIQUE KEY `index_origins_on_token` (`token`),
KEY `index_origins_on_domain_id` (`domain_id`),
KEY `index_origins_on_banned_by_user_id` (`banned_by_user_id`),
CONSTRAINT `fk_rails_28194a0343` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`),
CONSTRAINT `fk_rails_70b1f44aed` FOREIGN KEY (`banned_by_user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7949 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `read_ribbons`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `read_ribbons` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`is_following` tinyint(1) NOT NULL DEFAULT 1,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`story_id` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `index_read_ribbons_on_user_id` (`user_id`),
KEY `index_read_ribbons_on_story_id` (`story_id`),
CONSTRAINT `read_ribbons_story_id_fk` FOREIGN KEY (`story_id`) REFERENCES `stories` (`id`),
CONSTRAINT `read_ribbons_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=9351245 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `saved_stories`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `saved_stories` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`story_id` bigint(20) unsigned NOT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `index_saved_stories_on_user_id_and_story_id` (`user_id`,`story_id`),
UNIQUE KEY `index_saved_stories_on_token` (`token`),
KEY `saved_stories_story_id_fk` (`story_id`),
CONSTRAINT `saved_stories_story_id_fk` FOREIGN KEY (`story_id`) REFERENCES `stories` (`id`),
CONSTRAINT `saved_stories_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=227514 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `schema_migrations`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `schema_migrations` (
`version` varchar(255) NOT NULL,
PRIMARY KEY (`version`),
UNIQUE KEY `unique_schema_migrations` (`version`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `stories`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `stories` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime DEFAULT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`url` varchar(250) DEFAULT '',
`normalized_url` varchar(255) DEFAULT NULL,
`title` varchar(150) NOT NULL DEFAULT '',
`description` text DEFAULT NULL,
`short_id` char(6) NOT NULL DEFAULT '',
`is_deleted` tinyint(1) NOT NULL DEFAULT 0,
`score` int(11) NOT NULL DEFAULT 1,
`flags` int(10) unsigned NOT NULL DEFAULT 0,
`is_moderated` tinyint(1) NOT NULL DEFAULT 0,
`hotness` decimal(20,10) NOT NULL DEFAULT 0.0000000000,
`markeddown_description` mediumtext DEFAULT NULL,
`comments_count` int(11) NOT NULL DEFAULT 0,
`merged_story_id` bigint(20) unsigned DEFAULT NULL,
`unavailable_at` datetime DEFAULT NULL,
`twitter_id` varchar(20) DEFAULT NULL,
`user_is_author` tinyint(1) NOT NULL DEFAULT 0,
`user_is_following` tinyint(1) NOT NULL DEFAULT 0,
`domain_id` bigint(20) DEFAULT NULL,
`mastodon_id` varchar(25) DEFAULT NULL,
`origin_id` bigint(20) DEFAULT NULL,
`last_comment_at` datetime(6) DEFAULT NULL,
`stories_count` int(11) NOT NULL DEFAULT 0,
`updated_at` datetime(6) NOT NULL,
`last_edited_at` datetime(6) NOT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `unique_short_id` (`short_id`),
UNIQUE KEY `index_stories_on_token` (`token`),
KEY `url` (`url`(191)),
KEY `hotness_idx` (`hotness`),
KEY `index_stories_on_merged_story_id` (`merged_story_id`),
KEY `index_stories_on_created_at` (`created_at`),
KEY `index_stories_on_user_id` (`user_id`),
KEY `index_stories_on_domain_id` (`domain_id`),
KEY `index_stories_on_score` (`score`),
KEY `index_stories_on_id_and_is_deleted` (`id`,`is_deleted`),
KEY `index_stories_on_normalized_url` (`normalized_url`),
KEY `index_stories_on_mastodon_id` (`mastodon_id`),
KEY `index_stories_on_origin_id` (`origin_id`),
KEY `index_stories_on_last_comment_at` (`last_comment_at`),
CONSTRAINT `fk_rails_a04bca56b0` FOREIGN KEY (`domain_id`) REFERENCES `domains` (`id`),
CONSTRAINT `fk_rails_de71845285` FOREIGN KEY (`origin_id`) REFERENCES `origins` (`id`),
CONSTRAINT `stories_merged_story_id_fk` FOREIGN KEY (`merged_story_id`) REFERENCES `stories` (`id`) ON DELETE SET NULL,
CONSTRAINT `stories_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=122349 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `story_texts`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `story_texts` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`title` varchar(150) NOT NULL DEFAULT '',
`description` mediumtext DEFAULT NULL,
`body` mediumtext DEFAULT NULL,
`created_at` timestamp NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
PRIMARY KEY (`id`),
FULLTEXT KEY `index_story_texts_on_title_and_description_and_body` (`title`,`description`,`body`),
FULLTEXT KEY `index_story_texts_on_title` (`title`)
) ENGINE=InnoDB AUTO_INCREMENT=122349 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `suggested_taggings`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `suggested_taggings` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`story_id` bigint(20) unsigned NOT NULL,
`tag_id` bigint(20) unsigned NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `suggested_taggings_story_id_fk` (`story_id`),
KEY `suggested_taggings_tag_id_fk` (`tag_id`),
KEY `suggested_taggings_user_id_fk` (`user_id`),
CONSTRAINT `suggested_taggings_story_id_fk` FOREIGN KEY (`story_id`) REFERENCES `stories` (`id`),
CONSTRAINT `suggested_taggings_tag_id_fk` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`),
CONSTRAINT `suggested_taggings_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=28112 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `suggested_titles`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `suggested_titles` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`story_id` bigint(20) unsigned NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`title` varchar(150) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
KEY `suggested_titles_story_id_fk` (`story_id`),
KEY `suggested_titles_user_id_fk` (`user_id`),
CONSTRAINT `suggested_titles_story_id_fk` FOREIGN KEY (`story_id`) REFERENCES `stories` (`id`),
CONSTRAINT `suggested_titles_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5827 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `tag_filters`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `tag_filters` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`tag_id` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `user_tag_idx` (`user_id`,`tag_id`),
KEY `tag_filters_tag_id_fk` (`tag_id`),
CONSTRAINT `tag_filters_tag_id_fk` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`),
CONSTRAINT `tag_filters_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=26546 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `taggings`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `taggings` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`story_id` bigint(20) unsigned NOT NULL,
`tag_id` bigint(20) unsigned NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `story_id_tag_id` (`story_id`,`tag_id`),
KEY `taggings_tag_id_fk` (`tag_id`),
CONSTRAINT `taggings_story_id_fk` FOREIGN KEY (`story_id`) REFERENCES `stories` (`id`),
CONSTRAINT `taggings_tag_id_fk` FOREIGN KEY (`tag_id`) REFERENCES `tags` (`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB AUTO_INCREMENT=221344 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `tags`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `tags` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`tag` varchar(25) NOT NULL,
`description` varchar(100) DEFAULT NULL,
`privileged` tinyint(1) NOT NULL DEFAULT 0,
`is_media` tinyint(1) NOT NULL DEFAULT 0,
`active` tinyint(1) NOT NULL DEFAULT 1,
`hotness_mod` float DEFAULT 0,
`permit_by_new_users` tinyint(1) NOT NULL DEFAULT 1,
`category_id` bigint(20) NOT NULL,
`token` varchar(255) NOT NULL,
`created_at` datetime(6) NOT NULL,
`updated_at` datetime(6) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `tag` (`tag`),
UNIQUE KEY `index_tags_on_token` (`token`),
KEY `index_tags_on_category_id` (`category_id`),
CONSTRAINT `fk_rails_96a8141007` FOREIGN KEY (`category_id`) REFERENCES `categories` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=123 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `usernames`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `usernames` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`username` varchar(255) NOT NULL,
`user_id` bigint(20) unsigned NOT NULL,
`created_at` datetime(6) NOT NULL,
`renamed_away_at` datetime(6) DEFAULT NULL,
PRIMARY KEY (`id`),
KEY `fk_rails_74bbef8f63` (`user_id`),
CONSTRAINT `fk_rails_74bbef8f63` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=20808 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `users`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `users` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`username` varchar(50) DEFAULT NULL,
`email` varchar(100) DEFAULT NULL,
`password_digest` varchar(75) DEFAULT NULL,
`created_at` datetime DEFAULT NULL,
`is_admin` tinyint(1) NOT NULL DEFAULT 0,
`password_reset_token` varchar(75) DEFAULT NULL,
`session_token` varchar(75) NOT NULL DEFAULT '',
`about` mediumtext DEFAULT NULL,
`invited_by_user_id` bigint(20) unsigned DEFAULT NULL,
`is_moderator` tinyint(1) NOT NULL DEFAULT 0,
`pushover_mentions` tinyint(1) NOT NULL DEFAULT 0,
`rss_token` varchar(75) DEFAULT NULL,
`mailing_list_token` varchar(75) DEFAULT NULL,
`mailing_list_mode` int(11) DEFAULT 0,
`karma` int(11) NOT NULL DEFAULT 0,
`banned_at` datetime DEFAULT NULL,
`banned_by_user_id` bigint(20) unsigned DEFAULT NULL,
`banned_reason` varchar(256) DEFAULT NULL,
`deleted_at` datetime DEFAULT NULL,
`disabled_invite_at` datetime DEFAULT NULL,
`disabled_invite_by_user_id` bigint(20) unsigned DEFAULT NULL,
`disabled_invite_reason` varchar(200) DEFAULT NULL,
`settings` mediumtext DEFAULT NULL,
`show_email` tinyint(1) NOT NULL DEFAULT 0,
`last_read_newest_story` datetime(6) DEFAULT NULL,
`last_read_newest_comment` datetime(6) DEFAULT NULL,
`token` varchar(255) NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `session_hash` (`session_token`),
UNIQUE KEY `index_users_on_token` (`token`),
UNIQUE KEY `username` (`username`),
UNIQUE KEY `password_reset_token` (`password_reset_token`),
UNIQUE KEY `rss_token` (`rss_token`),
UNIQUE KEY `mailing_list_token` (`mailing_list_token`),
UNIQUE KEY `index_users_on_email` (`email`),
KEY `mailing_list_enabled` (`mailing_list_mode`),
KEY `users_banned_by_user_id_fk` (`banned_by_user_id`),
KEY `users_disabled_invite_by_user_id_fk` (`disabled_invite_by_user_id`),
KEY `users_invited_by_user_id_fk` (`invited_by_user_id`),
CONSTRAINT `users_banned_by_user_id_fk` FOREIGN KEY (`banned_by_user_id`) REFERENCES `users` (`id`),
CONSTRAINT `users_disabled_invite_by_user_id_fk` FOREIGN KEY (`disabled_invite_by_user_id`) REFERENCES `users` (`id`),
CONSTRAINT `users_invited_by_user_id_fk` FOREIGN KEY (`invited_by_user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=19630 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
DROP TABLE IF EXISTS `votes`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8mb4 */;
CREATE TABLE `votes` (
`id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`user_id` bigint(20) unsigned NOT NULL,
`story_id` bigint(20) unsigned NOT NULL,
`comment_id` bigint(20) unsigned DEFAULT NULL,
`vote` tinyint(4) NOT NULL,
`reason` varchar(1) NOT NULL DEFAULT '',
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`),
KEY `user_id_comment_id` (`user_id`,`comment_id`),
KEY `user_id_story_id` (`user_id`,`story_id`),
KEY `index_votes_on_comment_id` (`comment_id`),
KEY `votes_story_id_fk` (`story_id`),
CONSTRAINT `votes_comment_id_fk` FOREIGN KEY (`comment_id`) REFERENCES `comments` (`id`) ON DELETE CASCADE ON UPDATE CASCADE,
CONSTRAINT `votes_story_id_fk` FOREIGN KEY (`story_id`) REFERENCES `stories` (`id`),
CONSTRAINT `votes_user_id_fk` FOREIGN KEY (`user_id`) REFERENCES `users` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=4584040 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*M!100616 SET NOTE_VERBOSITY=@OLD_NOTE_VERBOSITY */;
INSERT INTO `schema_migrations` (version) VALUES
('20260106182240'),
('20251217042744'),
('20251217035703'),
('20251216222804'),
('20251216152019'),
('20251214222742'),
('20251214043426'),
('20251106162222'),
('20251106162039'),
('20251106155909'),
('20251106155022'),
('20251027163517'),
('20251013204007'),
('20250807160046'),
('20250728030009'),
('20250701121655'),
('20250630123615'),
('20250628172500'),
('20250605141223'),
('20250521131204'),
('20250516035743'),
('20250428193204'),
('20250424165830'),
('20250302102016'),
('20250210214901'),
('20250208222418'),
('20250206172739'),
('20250206170347'),
('20250203223624'),
('20250124063340'),
('20241106160424'),
('20241104215430'),
('20241017011246'),
('20241016200032'),
('20241016194903'),
('20241010165823'),
('20240926150737'),
('20240920115957'),
('20240909220644'),
('20240907171330'),
('20240822174547'),
('20240815145726'),
('20240813153242'),
('20240812221847'),
('20240717155412'),
('20240717144412'),
('20240608224626'),
('20240606084311'),
('20240315143804'),
('20240208024935'),
('20240207151341'),
('20231023155620'),
('20230923195457'),
('20230912160752'),
('20230828195756'),
('20230823150648'),
('20230424222719'),
('20220806200248'),
('20220331165136'),
('20220207033514'),
('20220128133226'),
('20200828015742'),
('20200820170829'),
('20200812024241'),
('20200811022248'),
('20200809023435'),
('20200807021926'),
('20200607192351'),
('20200519000845'),
('20200210155624'),
('20200210125425'),
('20191227234358'),
('20191227232955'),
('20191029021735'),
('20191010172004'),
('20190529133507'),
('20181202194809'),
('20181005192331'),
('20181003234523'),
('20180926134230'),
('20180830114325'),
('20180711123439'),
('20180705143850'),
('20180506045709'),
('20180503150810'),
('20180501031849'),
('20180411131217'),
('20180201184612'),
('20180201172618'),
('20180201041055'),
('20180201024840'),
('20180131203555'),
('20180131170318'),
('20180130235553'),
('20180124143340'),
('20171025072230'),
('20171018034551'),
('20170713195446'),
('20170607170604'),
('20170607153224'),
('20170522144135'),
('20170413161450'),
('20170413015646'),
('20170412131313'),
('20170225201811'),
('20170119192703'),
('20170119172852'),
('20160704022756'),
('20160515162433'),
('20160406160019'),
('20160331021113'),
('20151207180050'),
('20151015143959'),
('20151015011231'),
('20151015005101'),
('20150730225352'),
('20150730215915'),
('20150313040930'),
('20150224035617'),
('20150211170052'),
('20150127180326'),
('20150115172138'),
('20150106195555'),
('20141114184921'),
('20140901013149'),
('20140825225915'),
('20140804005415'),
('20140701153554'),
('20140408160306'),
('20140221164400'),
('20140219183804'),
('20140121063641'),
('20140113153413'),
('20140112192936'),
('20140109034338'),
('20140106205200'),
('20140101202252'),
('20131228175805'),
('20131018201413'),
('20130622021035'),
('20130526164230'),
('20121112165212'),
('20121004153529'),
('20120919195401'),
('20120918152116'),
('20120910172514'),
('20120906183346'),
('20120902143549'),
('20120816203248'),
('20120712174445'),
('20120706221602'),
('20120705145520'),
('20120704025956'),
('20120704013019'),
('20120704004020'),
('20120703184957'),
('20120701181319'),
('20120701160006'),
('20120701154453');
CREATE TABLE IF NOT EXISTS "action_mailbox_inbound_emails" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "status" integer DEFAULT 0 NOT NULL, "message_id" varchar NOT NULL, "message_checksum" varchar NOT NULL, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL);
CREATE UNIQUE INDEX "index_action_mailbox_inbound_emails_uniqueness" ON "action_mailbox_inbound_emails" ("message_id", "message_checksum");
CREATE TABLE IF NOT EXISTS "active_storage_blobs" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "key" varchar NOT NULL, "filename" varchar NOT NULL, "content_type" varchar, "metadata" text, "service_name" varchar NOT NULL, "byte_size" bigint NOT NULL, "checksum" varchar, "created_at" datetime(6) NOT NULL);
CREATE UNIQUE INDEX "index_active_storage_blobs_on_key" ON "active_storage_blobs" ("key");
CREATE TABLE IF NOT EXISTS "categories" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "category" varchar(25) COLLATE "NOCASE" NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "token" varchar NOT NULL);
CREATE UNIQUE INDEX "index_categories_on_category" ON "categories" ("category");
CREATE UNIQUE INDEX "index_categories_on_token" ON "categories" ("token");
CREATE TABLE IF NOT EXISTS "comment_stats" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "date" date NOT NULL, "average" integer NOT NULL);
CREATE UNIQUE INDEX "index_comment_stats_on_date" ON "comment_stats" ("date");
CREATE TABLE IF NOT EXISTS "invitation_requests" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "code" varchar, "is_verified" boolean DEFAULT 0 NOT NULL, "email" varchar NOT NULL, "name" varchar NOT NULL, "memo" text, "ip_address" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "token" varchar NOT NULL);
CREATE UNIQUE INDEX "index_invitation_requests_on_token" ON "invitation_requests" ("token");
CREATE TABLE IF NOT EXISTS "keystores" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "key" varchar(50) DEFAULT '' NOT NULL, "value" bigint);
CREATE UNIQUE INDEX "key" ON "keystores" ("key");
CREATE TABLE IF NOT EXISTS "mastodon_apps" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL, "client_id" varchar NOT NULL, "client_secret" varchar NOT NULL, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL);
CREATE UNIQUE INDEX "index_mastodon_apps_on_name" ON "mastodon_apps" ("name");
CREATE TABLE IF NOT EXISTS "mod_activities" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "item_type" varchar NOT NULL, "item_id" bigint NOT NULL, "token" varchar NOT NULL, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL);
CREATE UNIQUE INDEX "index_mod_activities_on_item_type_and_item_id" ON "mod_activities" ("item_type", "item_id");
CREATE UNIQUE INDEX "index_mod_activities_on_token" ON "mod_activities" ("token");
CREATE TABLE IF NOT EXISTS "mod_mails" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "subject" varchar NOT NULL, "remind_mods_at" datetime(6), "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL, "short_id" varchar(10) NOT NULL);
CREATE UNIQUE INDEX "index_mod_mails_on_short_id" ON "mod_mails" ("short_id");
CREATE TABLE IF NOT EXISTS "story_texts" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar(150) DEFAULT '' NOT NULL, "description" text, "body" text, "created_at" datetime(6) DEFAULT (now()) NOT NULL);
CREATE TABLE IF NOT EXISTS "active_storage_attachments" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "name" varchar NOT NULL, "record_type" varchar NOT NULL, "record_id" bigint NOT NULL, "blob_id" bigint NOT NULL, "created_at" datetime(6) NOT NULL, CONSTRAINT "fk_rails_c3b3935057"
FOREIGN KEY ("blob_id")
REFERENCES "active_storage_blobs" ("id")
);
CREATE INDEX "index_active_storage_attachments_on_blob_id" ON "active_storage_attachments" ("blob_id");
CREATE UNIQUE INDEX "index_active_storage_attachments_uniqueness" ON "active_storage_attachments" ("record_type", "record_id", "name", "blob_id");
CREATE TABLE IF NOT EXISTS "active_storage_variant_records" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "blob_id" bigint NOT NULL, "variation_digest" varchar NOT NULL, CONSTRAINT "fk_rails_993965df05"
FOREIGN KEY ("blob_id")
REFERENCES "active_storage_blobs" ("id")
);
CREATE UNIQUE INDEX "index_active_storage_variant_records_uniqueness" ON "active_storage_variant_records" ("blob_id", "variation_digest");
CREATE TABLE IF NOT EXISTS "comments" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime, "short_id" varchar(10) DEFAULT '' NOT NULL, "story_id" bigint NOT NULL, "confidence_order" blob(3) NOT NULL, "user_id" bigint NOT NULL, "parent_comment_id" bigint, "thread_id" bigint, "comment" text NOT NULL, "score" integer DEFAULT 1 NOT NULL, "flags" integer DEFAULT 0 NOT NULL, "confidence" decimal(20,19) DEFAULT 0.0 NOT NULL, "markeddown_comment" text, "is_deleted" boolean DEFAULT 0 NOT NULL, "is_moderated" boolean DEFAULT 0 NOT NULL, "is_from_email" boolean DEFAULT 0 NOT NULL, "hat_id" bigint, "depth" integer DEFAULT 0 NOT NULL, "reply_count" integer DEFAULT 0 NOT NULL, "last_reply_at" datetime(6), "last_edited_at" datetime(6) NOT NULL, "token" varchar NOT NULL, CONSTRAINT "fk_rails_a6629c2afc"
FOREIGN KEY ("story_id")
REFERENCES "stories" ("id")
, CONSTRAINT "fk_rails_da28d53ee7"
FOREIGN KEY ("parent_comment_id")
REFERENCES "comments" ("id")
, CONSTRAINT "fk_rails_2fba5a9193"
FOREIGN KEY ("hat_id")
REFERENCES "hats" ("id")
, CONSTRAINT "fk_rails_03de2dc08c"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "confidence_idx" ON "comments" ("confidence");
CREATE INDEX "comments_hat_id_fk" ON "comments" ("hat_id");
CREATE INDEX "comments_parent_comment_id_fk" ON "comments" ("parent_comment_id");
CREATE INDEX "index_comments_on_score" ON "comments" ("score");
CREATE UNIQUE INDEX "short_id" ON "comments" ("short_id");
CREATE INDEX "story_id_short_id" ON "comments" ("story_id", "short_id");
CREATE INDEX "thread_id" ON "comments" ("thread_id");
CREATE UNIQUE INDEX "index_comments_on_token" ON "comments" ("token");
CREATE INDEX "index_comments_on_user_id" ON "comments" ("user_id");
CREATE TABLE IF NOT EXISTS "domains" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "domain" varchar NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "banned_at" datetime, "banned_by_user_id" bigint, "banned_reason" varchar(200), "selector" varchar, "replacement" varchar, "stories_count" integer DEFAULT 0 NOT NULL, "token" varchar NOT NULL, CONSTRAINT "fk_rails_c15837f026"
FOREIGN KEY ("banned_by_user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "index_domains_on_banned_by_user_id" ON "domains" ("banned_by_user_id");
CREATE UNIQUE INDEX "index_domains_on_domain" ON "domains" ("domain");
CREATE UNIQUE INDEX "index_domains_on_token" ON "domains" ("token");
CREATE TABLE IF NOT EXISTS "hat_requests" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime, "updated_at" datetime, "user_id" bigint NOT NULL, "hat" varchar NOT NULL, "link" varchar NOT NULL, "comment" text NOT NULL, "token" varchar NOT NULL, CONSTRAINT "fk_rails_9877748d2d"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE UNIQUE INDEX "index_hat_requests_on_token" ON "hat_requests" ("token");
CREATE INDEX "hat_requests_user_id_fk" ON "hat_requests" ("user_id");
CREATE TABLE IF NOT EXISTS "hats" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime, "updated_at" datetime, "user_id" bigint NOT NULL, "granted_by_user_id" bigint NOT NULL, "hat" varchar NOT NULL, "link" varchar, "modlog_use" boolean DEFAULT 0 NOT NULL, "doffed_at" datetime, "short_id" varchar(10) NOT NULL, "token" varchar NOT NULL, CONSTRAINT "fk_rails_b350828d0c"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
, CONSTRAINT "fk_rails_f3a75534d5"
FOREIGN KEY ("granted_by_user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "hats_granted_by_user_id_fk" ON "hats" ("granted_by_user_id");
CREATE UNIQUE INDEX "index_hats_on_token" ON "hats" ("token");
CREATE INDEX "hats_user_id_fk" ON "hats" ("user_id");
CREATE TABLE IF NOT EXISTS "hidden_stories" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" bigint NOT NULL, "story_id" bigint NOT NULL, "created_at" datetime(6), "token" varchar NOT NULL, CONSTRAINT "fk_rails_51784d0457"
FOREIGN KEY ("story_id")
REFERENCES "stories" ("id")
, CONSTRAINT "fk_rails_769e10ecde"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "hidden_stories_story_id_fk" ON "hidden_stories" ("story_id");
CREATE UNIQUE INDEX "index_hidden_stories_on_token" ON "hidden_stories" ("token");
CREATE UNIQUE INDEX "index_hidden_stories_on_user_id_and_story_id" ON "hidden_stories" ("user_id", "story_id");
CREATE TABLE IF NOT EXISTS "invitations" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" bigint NOT NULL, "email" varchar, "code" varchar, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "memo" text, "used_at" datetime, "new_user_id" bigint, "token" varchar NOT NULL, CONSTRAINT "fk_rails_7eae413fe6"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
, CONSTRAINT "fk_rails_9fa4066754"
FOREIGN KEY ("new_user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "invitations_new_user_id_fk" ON "invitations" ("new_user_id");
CREATE UNIQUE INDEX "index_invitations_on_token" ON "invitations" ("token");
CREATE INDEX "invitations_user_id_fk" ON "invitations" ("user_id");
CREATE TABLE IF NOT EXISTS "links" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "url" varchar(250) NOT NULL, "normalized_url" varchar NOT NULL, "title" varchar, "from_story_id" bigint, "from_comment_id" bigint, "to_story_id" bigint, "to_comment_id" bigint, CONSTRAINT "fk_rails_d7bbd2b475"
FOREIGN KEY ("from_story_id")
REFERENCES "stories" ("id")
, CONSTRAINT "fk_rails_51de50cb3b"
FOREIGN KEY ("from_comment_id")
REFERENCES "comments" ("id")
, CONSTRAINT "fk_rails_ac0932f49b"
FOREIGN KEY ("to_comment_id")
REFERENCES "comments" ("id")
, CONSTRAINT "fk_rails_f04e4c6073"
FOREIGN KEY ("to_story_id")
REFERENCES "stories" ("id")
);
CREATE INDEX "index_links_on_from_comment_id" ON "links" ("from_comment_id");
CREATE INDEX "index_links_on_from_story_id" ON "links" ("from_story_id");
CREATE INDEX "index_links_on_normalized_url" ON "links" ("normalized_url");
CREATE UNIQUE INDEX "idx_links_on_to_comment_id_and_from_story_id_and_from_comment_id" ON "links" ("to_comment_id", "from_story_id", "from_comment_id");
CREATE UNIQUE INDEX "index_links_on_to_story_id_and_from_story_id_and_from_comment_id" ON "links" ("to_story_id", "from_story_id", "from_comment_id");
CREATE UNIQUE INDEX "index_links_on_url_and_from_story_id_and_from_comment_id" ON "links" ("url", "from_story_id", "from_comment_id");
CREATE TABLE IF NOT EXISTS "messages" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime, "author_user_id" bigint, "recipient_user_id" bigint NOT NULL, "subject" varchar(100), "body" text, "short_id" varchar(30) DEFAULT '' NOT NULL, "deleted_by_author" boolean DEFAULT 0 NOT NULL, "deleted_by_recipient" boolean DEFAULT 0 NOT NULL, "hat_id" bigint, "token" varchar NOT NULL, CONSTRAINT "fk_rails_013215d0ae"
FOREIGN KEY ("author_user_id")
REFERENCES "users" ("id")
, CONSTRAINT "fk_rails_3eec69e54a"
FOREIGN KEY ("hat_id")
REFERENCES "hats" ("id")
, CONSTRAINT "fk_rails_e66dbea9ab"
FOREIGN KEY ("recipient_user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "index_messages_on_author_user_id" ON "messages" ("author_user_id");
CREATE INDEX "index_messages_on_hat_id" ON "messages" ("hat_id");
CREATE INDEX "messages_recipient_user_id_fk" ON "messages" ("recipient_user_id");
CREATE UNIQUE INDEX "random_hash" ON "messages" ("short_id");
CREATE UNIQUE INDEX "index_messages_on_token" ON "messages" ("token");
CREATE TABLE IF NOT EXISTS "mod_mail_messages" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "mod_mail_id" bigint NOT NULL, "message" text NOT NULL, "user_id" bigint NOT NULL, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL, CONSTRAINT "fk_rails_58a2afacf2"
FOREIGN KEY ("mod_mail_id")
REFERENCES "mod_mails" ("id")
, CONSTRAINT "fk_rails_40fa20cab5"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "index_mod_mail_messages_on_mod_mail_id" ON "mod_mail_messages" ("mod_mail_id");
CREATE INDEX "fk_rails_40fa20cab5" ON "mod_mail_messages" ("user_id");
CREATE TABLE IF NOT EXISTS "mod_mail_recipients" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "mod_mail_id" bigint NOT NULL, "user_id" bigint NOT NULL, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL, CONSTRAINT "fk_rails_4b3ed28906"
FOREIGN KEY ("mod_mail_id")
REFERENCES "mod_mails" ("id")
, CONSTRAINT "fk_rails_7a6d5232be"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "index_mod_mail_recipients_on_mod_mail_id" ON "mod_mail_recipients" ("mod_mail_id");
CREATE INDEX "fk_rails_7a6d5232be" ON "mod_mail_recipients" ("user_id");
CREATE TABLE IF NOT EXISTS "mod_mail_references" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "mod_mail_id" bigint NOT NULL, "reference_type" varchar NOT NULL, "reference_id" bigint NOT NULL, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL, CONSTRAINT "fk_rails_2508982161"
FOREIGN KEY ("mod_mail_id")
REFERENCES "mod_mails" ("id")
);
CREATE INDEX "index_mod_mail_references_on_mod_mail_id" ON "mod_mail_references" ("mod_mail_id");
CREATE INDEX "index_mod_mail_references_on_reference" ON "mod_mail_references" ("reference_type", "reference_id");
CREATE TABLE IF NOT EXISTS "mod_notes" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "moderator_user_id" bigint NOT NULL, "user_id" bigint NOT NULL, "note" text NOT NULL, "markeddown_note" text NOT NULL, "created_at" datetime NOT NULL, "token" varchar NOT NULL, CONSTRAINT "fk_rails_ed47d52fe1"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
, CONSTRAINT "fk_rails_55ec82c4cf"
FOREIGN KEY ("moderator_user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "index_mod_notes_on_id_and_user_id" ON "mod_notes" ("id", "user_id");
CREATE INDEX "mod_notes_moderator_user_id_fk" ON "mod_notes" ("moderator_user_id");
CREATE UNIQUE INDEX "index_mod_notes_on_token" ON "mod_notes" ("token");
CREATE INDEX "mod_notes_user_id_fk" ON "mod_notes" ("user_id");
CREATE TABLE IF NOT EXISTS "moderations" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "moderator_user_id" bigint, "story_id" bigint, "comment_id" bigint, "user_id" bigint, "action" text NOT NULL, "reason" text, "is_from_suggestions" boolean DEFAULT 0 NOT NULL, "tag_id" bigint, "domain_id" bigint, "category_id" bigint, "origin_id" bigint, "token" varchar NOT NULL, CONSTRAINT "fk_rails_ac858bba09"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
, CONSTRAINT "fk_rails_c363ae32f8"
FOREIGN KEY ("story_id")
REFERENCES "stories" ("id")
, CONSTRAINT "fk_rails_b95b064e59"
FOREIGN KEY ("domain_id")
REFERENCES "domains" ("id")
, CONSTRAINT "fk_rails_a286a4afe4"
FOREIGN KEY ("category_id")
REFERENCES "categories" ("id")
, CONSTRAINT "fk_rails_da14048a9d"
FOREIGN KEY ("comment_id")
REFERENCES "comments" ("id")
, CONSTRAINT "fk_rails_babb42ccfe"
FOREIGN KEY ("origin_id")
REFERENCES "origins" ("id")
, CONSTRAINT "fk_rails_a57ee35425"
FOREIGN KEY ("tag_id")
REFERENCES "tags" ("id")
, CONSTRAINT "fk_rails_b780b7361d"
FOREIGN KEY ("moderator_user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "index_moderations_on_category_id" ON "moderations" ("category_id");
CREATE INDEX "moderations_comment_id_fk" ON "moderations" ("comment_id");
CREATE INDEX "index_moderations_on_created_at" ON "moderations" ("created_at");
CREATE INDEX "index_moderations_on_domain_id" ON "moderations" ("domain_id");
CREATE INDEX "moderations_moderator_user_id_fk" ON "moderations" ("moderator_user_id");
CREATE INDEX "index_moderations_on_origin_id" ON "moderations" ("origin_id");
CREATE INDEX "moderations_story_id_fk" ON "moderations" ("story_id");
CREATE INDEX "moderations_tag_id_fk" ON "moderations" ("tag_id");
CREATE UNIQUE INDEX "index_moderations_on_token" ON "moderations" ("token");
CREATE INDEX "index_moderations_on_user_id" ON "moderations" ("user_id");
CREATE TABLE IF NOT EXISTS "notifications" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" bigint NOT NULL, "notifiable_type" varchar NOT NULL, "notifiable_id" bigint NOT NULL, "read_at" datetime(6), "token" varchar NOT NULL, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL, CONSTRAINT "fk_rails_b080fb4855"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "index_notifications_on_notifiable" ON "notifications" ("notifiable_type", "notifiable_id");
CREATE UNIQUE INDEX "index_notifications_on_token" ON "notifications" ("token");
CREATE UNIQUE INDEX "idx_on_user_id_notifiable_type_notifiable_id_ffac34041e" ON "notifications" ("user_id", "notifiable_type", "notifiable_id");
CREATE TABLE IF NOT EXISTS "origins" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "domain_id" bigint NOT NULL, "identifier" varchar NOT NULL, "stories_count" integer DEFAULT 0 NOT NULL, "banned_at" datetime(6), "banned_by_user_id" bigint, "banned_reason" varchar(200), "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL, "token" varchar NOT NULL, CONSTRAINT "fk_rails_28194a0343"
FOREIGN KEY ("domain_id")
REFERENCES "domains" ("id")
, CONSTRAINT "fk_rails_70b1f44aed"
FOREIGN KEY ("banned_by_user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "index_origins_on_banned_by_user_id" ON "origins" ("banned_by_user_id");
CREATE INDEX "index_origins_on_domain_id" ON "origins" ("domain_id");
CREATE UNIQUE INDEX "index_origins_on_identifier" ON "origins" ("identifier");
CREATE UNIQUE INDEX "index_origins_on_token" ON "origins" ("token");
CREATE TABLE IF NOT EXISTS "read_ribbons" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "is_following" boolean DEFAULT 1 NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "user_id" bigint NOT NULL, "story_id" bigint NOT NULL, CONSTRAINT "fk_rails_6b6faf6ddb"
FOREIGN KEY ("story_id")
REFERENCES "stories" ("id")
, CONSTRAINT "fk_rails_b5dafaf9c3"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "index_read_ribbons_on_story_id" ON "read_ribbons" ("story_id");
CREATE INDEX "index_read_ribbons_on_user_id" ON "read_ribbons" ("user_id");
CREATE TABLE IF NOT EXISTS "saved_stories" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "user_id" bigint NOT NULL, "story_id" bigint NOT NULL, "token" varchar NOT NULL, CONSTRAINT "fk_rails_eda99b7dc5"
FOREIGN KEY ("story_id")
REFERENCES "stories" ("id")
, CONSTRAINT "fk_rails_83c41665d2"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "saved_stories_story_id_fk" ON "saved_stories" ("story_id");
CREATE UNIQUE INDEX "index_saved_stories_on_token" ON "saved_stories" ("token");
CREATE UNIQUE INDEX "index_saved_stories_on_user_id_and_story_id" ON "saved_stories" ("user_id", "story_id");
CREATE TABLE IF NOT EXISTS "stories" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime, "user_id" bigint NOT NULL, "url" varchar(250) DEFAULT '', "normalized_url" varchar, "title" varchar(150) DEFAULT '' NOT NULL, "description" text, "short_id" varchar(6) DEFAULT '' NOT NULL, "is_deleted" boolean DEFAULT 0 NOT NULL, "score" integer DEFAULT 1 NOT NULL, "flags" integer DEFAULT 0 NOT NULL, "is_moderated" boolean DEFAULT 0 NOT NULL, "hotness" decimal(20,10) DEFAULT 0.0 NOT NULL, "markeddown_description" text, "comments_count" integer DEFAULT 0 NOT NULL, "merged_story_id" bigint, "unavailable_at" datetime, "twitter_id" varchar(20), "user_is_author" boolean DEFAULT 0 NOT NULL, "user_is_following" boolean DEFAULT 0 NOT NULL, "domain_id" bigint, "mastodon_id" varchar(25), "origin_id" bigint, "last_comment_at" datetime(6), "stories_count" integer DEFAULT 0 NOT NULL, "updated_at" datetime(6) NOT NULL, "last_edited_at" datetime(6) NOT NULL, "token" varchar NOT NULL, CONSTRAINT "fk_rails_1b83c06574"
FOREIGN KEY ("merged_story_id")
REFERENCES "stories" ("id")
ON DELETE SET NULL, CONSTRAINT "fk_rails_a04bca56b0"
FOREIGN KEY ("domain_id")
REFERENCES "domains" ("id")
, CONSTRAINT "fk_rails_de71845285"
FOREIGN KEY ("origin_id")
REFERENCES "origins" ("id")
, CONSTRAINT "fk_rails_c53f5feaac"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "index_stories_on_created_at" ON "stories" ("created_at");
CREATE INDEX "index_stories_on_domain_id" ON "stories" ("domain_id");
CREATE INDEX "hotness_idx" ON "stories" ("hotness");
CREATE INDEX "index_stories_on_id_and_is_deleted" ON "stories" ("id", "is_deleted");
CREATE INDEX "index_stories_on_last_comment_at" ON "stories" ("last_comment_at");
CREATE INDEX "index_stories_on_mastodon_id" ON "stories" ("mastodon_id");
CREATE INDEX "index_stories_on_merged_story_id" ON "stories" ("merged_story_id");
CREATE INDEX "index_stories_on_normalized_url" ON "stories" ("normalized_url");
CREATE INDEX "index_stories_on_origin_id" ON "stories" ("origin_id");
CREATE INDEX "index_stories_on_score" ON "stories" ("score");
CREATE UNIQUE INDEX "unique_short_id" ON "stories" ("short_id");
CREATE UNIQUE INDEX "index_stories_on_token" ON "stories" ("token");
CREATE INDEX "url" ON "stories" ("url");
CREATE INDEX "index_stories_on_user_id" ON "stories" ("user_id");
CREATE TABLE IF NOT EXISTS "suggested_taggings" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "story_id" bigint NOT NULL, "tag_id" bigint NOT NULL, "user_id" bigint NOT NULL, CONSTRAINT "fk_rails_acdb4e46b2"
FOREIGN KEY ("tag_id")
REFERENCES "tags" ("id")
, CONSTRAINT "fk_rails_fe2ea7bf5f"
FOREIGN KEY ("story_id")
REFERENCES "stories" ("id")
, CONSTRAINT "fk_rails_1df34a0fde"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "suggested_taggings_story_id_fk" ON "suggested_taggings" ("story_id");
CREATE INDEX "suggested_taggings_tag_id_fk" ON "suggested_taggings" ("tag_id");
CREATE INDEX "suggested_taggings_user_id_fk" ON "suggested_taggings" ("user_id");
CREATE TABLE IF NOT EXISTS "suggested_titles" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "story_id" bigint NOT NULL, "user_id" bigint NOT NULL, "title" varchar(150) DEFAULT '' NOT NULL, CONSTRAINT "fk_rails_6b591a1da4"
FOREIGN KEY ("story_id")
REFERENCES "stories" ("id")
, CONSTRAINT "fk_rails_787f0dbdd3"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "suggested_titles_story_id_fk" ON "suggested_titles" ("story_id");
CREATE INDEX "suggested_titles_user_id_fk" ON "suggested_titles" ("user_id");
CREATE TABLE IF NOT EXISTS "tag_filters" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "user_id" bigint NOT NULL, "tag_id" bigint NOT NULL, CONSTRAINT "fk_rails_0d7395554e"
FOREIGN KEY ("tag_id")
REFERENCES "tags" ("id")
, CONSTRAINT "fk_rails_25f1c4c2fe"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "tag_filters_tag_id_fk" ON "tag_filters" ("tag_id");
CREATE INDEX "user_tag_idx" ON "tag_filters" ("user_id", "tag_id");
CREATE TABLE IF NOT EXISTS "taggings" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "story_id" bigint NOT NULL, "tag_id" bigint NOT NULL, CONSTRAINT "fk_rails_3a20720060"
FOREIGN KEY ("story_id")
REFERENCES "stories" ("id")
, CONSTRAINT "fk_rails_9fcd2e236b"
FOREIGN KEY ("tag_id")
REFERENCES "tags" ("id")
ON DELETE CASCADE ON UPDATE CASCADE);
CREATE UNIQUE INDEX "story_id_tag_id" ON "taggings" ("story_id", "tag_id");
CREATE INDEX "taggings_tag_id_fk" ON "taggings" ("tag_id");
CREATE TABLE IF NOT EXISTS "tags" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "tag" varchar(25) COLLATE "NOCASE" NOT NULL, "description" varchar(100), "privileged" boolean DEFAULT 0 NOT NULL, "is_media" boolean DEFAULT 0 NOT NULL, "active" boolean DEFAULT 1 NOT NULL, "hotness_mod" float DEFAULT 0.0, "permit_by_new_users" boolean DEFAULT 1 NOT NULL, "category_id" bigint NOT NULL, "token" varchar NOT NULL, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL, CONSTRAINT "fk_rails_96a8141007"
FOREIGN KEY ("category_id")
REFERENCES "categories" ("id")
);
CREATE INDEX "index_tags_on_category_id" ON "tags" ("category_id");
CREATE UNIQUE INDEX "tag" ON "tags" ("tag");
CREATE UNIQUE INDEX "index_tags_on_token" ON "tags" ("token");
CREATE TABLE IF NOT EXISTS "usernames" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar NOT NULL, "user_id" bigint NOT NULL, "created_at" datetime(6) NOT NULL, "renamed_away_at" datetime(6), CONSTRAINT "fk_rails_74bbef8f63"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "fk_rails_74bbef8f63" ON "usernames" ("user_id");
CREATE TABLE IF NOT EXISTS "users" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "username" varchar(50) COLLATE "NOCASE", "email" varchar(100), "password_digest" varchar(75), "created_at" datetime, "is_admin" boolean DEFAULT 0 NOT NULL, "password_reset_token" varchar(75), "session_token" varchar(75) DEFAULT '' NOT NULL, "about" text, "invited_by_user_id" bigint, "is_moderator" boolean DEFAULT 0 NOT NULL, "pushover_mentions" boolean DEFAULT 0 NOT NULL, "rss_token" varchar(75), "mailing_list_token" varchar(75), "mailing_list_mode" integer DEFAULT 0, "karma" integer DEFAULT 0 NOT NULL, "banned_at" datetime, "banned_by_user_id" bigint, "banned_reason" varchar(256), "deleted_at" datetime, "disabled_invite_at" datetime, "disabled_invite_by_user_id" bigint, "disabled_invite_reason" varchar(200), "settings" text, "show_email" boolean DEFAULT 0 NOT NULL, "last_read_newest_story" datetime(6), "last_read_newest_comment" datetime(6), "token" varchar NOT NULL, CONSTRAINT "fk_rails_9ef0fc92c3"
FOREIGN KEY ("disabled_invite_by_user_id")
REFERENCES "users" ("id")
, CONSTRAINT "fk_rails_7e442ad29a"
FOREIGN KEY ("banned_by_user_id")
REFERENCES "users" ("id")
, CONSTRAINT "fk_rails_bc76119071"
FOREIGN KEY ("invited_by_user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "users_banned_by_user_id_fk" ON "users" ("banned_by_user_id");
CREATE INDEX "users_disabled_invite_by_user_id_fk" ON "users" ("disabled_invite_by_user_id");
CREATE UNIQUE INDEX "index_users_on_email" ON "users" ("email");
CREATE INDEX "users_invited_by_user_id_fk" ON "users" ("invited_by_user_id");
CREATE INDEX "mailing_list_enabled" ON "users" ("mailing_list_mode");
CREATE UNIQUE INDEX "mailing_list_token" ON "users" ("mailing_list_token");
CREATE UNIQUE INDEX "password_reset_token" ON "users" ("password_reset_token");
CREATE UNIQUE INDEX "rss_token" ON "users" ("rss_token");
CREATE UNIQUE INDEX "session_hash" ON "users" ("session_token");
CREATE UNIQUE INDEX "index_users_on_token" ON "users" ("token");
CREATE UNIQUE INDEX "username" ON "users" ("username");
CREATE TABLE IF NOT EXISTS "votes" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" bigint NOT NULL, "story_id" bigint NOT NULL, "comment_id" bigint, "vote" integer(1) NOT NULL, "reason" varchar(1) DEFAULT '' NOT NULL, "updated_at" datetime NOT NULL, CONSTRAINT "fk_rails_ddb4691ef0"
FOREIGN KEY ("story_id")
REFERENCES "stories" ("id")
, CONSTRAINT "fk_rails_2e88a155f7"
FOREIGN KEY ("comment_id")
REFERENCES "comments" ("id")
ON DELETE CASCADE ON UPDATE CASCADE, CONSTRAINT "fk_rails_c9b3bef597"
FOREIGN KEY ("user_id")
REFERENCES "users" ("id")
);
CREATE INDEX "index_votes_on_comment_id" ON "votes" ("comment_id");
CREATE INDEX "votes_story_id_fk" ON "votes" ("story_id");
CREATE INDEX "user_id_comment_id" ON "votes" ("user_id", "comment_id");
CREATE INDEX "user_id_story_id" ON "votes" ("user_id", "story_id");
CREATE VIRTUAL TABLE comments_fts USING fts5 (comment, content='', contentless_delete=1)
/* comments_fts(comment) */;
CREATE TABLE IF NOT EXISTS 'comments_fts_data'(id INTEGER PRIMARY KEY, block BLOB);
CREATE TABLE IF NOT EXISTS 'comments_fts_idx'(segid, term, pgno, PRIMARY KEY(segid, term)) WITHOUT ROWID;
CREATE TABLE IF NOT EXISTS 'comments_fts_docsize'(id INTEGER PRIMARY KEY, sz BLOB, origin INTEGER);
CREATE TABLE IF NOT EXISTS 'comments_fts_config'(k PRIMARY KEY, v) WITHOUT ROWID;
CREATE VIRTUAL TABLE story_texts_fts USING fts5 (title, description, body, content='', contentless_delete=1)
/* story_texts_fts(title,description,body) */;
CREATE TABLE IF NOT EXISTS 'story_texts_fts_data'(id INTEGER PRIMARY KEY, block BLOB);
CREATE TABLE IF NOT EXISTS 'story_texts_fts_idx'(segid, term, pgno, PRIMARY KEY(segid, term)) WITHOUT ROWID;
CREATE TABLE IF NOT EXISTS 'story_texts_fts_docsize'(id INTEGER PRIMARY KEY, sz BLOB, origin INTEGER);
CREATE TABLE IF NOT EXISTS 'story_texts_fts_config'(k PRIMARY KEY, v) WITHOUT ROWID;
CREATE TABLE IF NOT EXISTS "schema_migrations" ("version" varchar NOT NULL PRIMARY KEY);
CREATE TABLE IF NOT EXISTS "ar_internal_metadata" ("key" varchar NOT NULL PRIMARY KEY, "value" varchar, "created_at" datetime(6) NOT NULL, "updated_at" datetime(6) NOT NULL);
INSERT INTO "schema_migrations" (version) VALUES
('20260128183915'),
('20251217042744'),
('20251217035703'),
('20251216222804'),
('20251216152019'),
('20251214222742'),
('20251214043426'),
('20250818183847'),
('20250818182728');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment