2019-09-01 05:57:42 +00:00
|
|
|
USE `fedibooks`;
|
2019-08-31 10:34:45 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS `users` (
|
2019-09-01 09:53:38 +00:00
|
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
2019-08-31 10:34:45 +00:00
|
|
|
`email` VARCHAR(128) UNIQUE NOT NULL,
|
2019-09-01 09:57:49 +00:00
|
|
|
`password` BINARY(60) NOT NULL,
|
2019-09-10 01:17:06 +00:00
|
|
|
`email_verified` BOOLEAN DEFAULT 0,
|
2019-08-31 10:34:45 +00:00
|
|
|
`fetch` ENUM('always', 'once', 'never') DEFAULT 'once',
|
|
|
|
`submit` ENUM('always', 'once', 'never') DEFAULT 'once',
|
|
|
|
`generation` ENUM('always', 'once', 'never') DEFAULT 'once',
|
2019-09-01 09:57:49 +00:00
|
|
|
`reply` ENUM('always', 'once', 'never') DEFAULT 'once'
|
2019-09-01 06:10:30 +00:00
|
|
|
) ENGINE=INNODB;
|
|
|
|
CREATE TABLE IF NOT EXISTS `credentials` (
|
|
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
`client_id` VARCHAR(128) NOT NULL,
|
|
|
|
`client_secret` VARCHAR(128) NOT NULL,
|
|
|
|
`secret` VARCHAR(128) NOT NULL
|
2019-09-01 06:02:25 +00:00
|
|
|
) ENGINE=INNODB;
|
2019-08-31 10:34:45 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS `bots` (
|
2019-09-02 06:36:42 +00:00
|
|
|
`handle` VARCHAR(128) PRIMARY KEY,
|
2019-09-01 09:53:38 +00:00
|
|
|
`user_id` INT NOT NULL,
|
2019-09-01 06:01:53 +00:00
|
|
|
`credentials_id` INT NOT NULL,
|
2019-09-03 04:17:20 +00:00
|
|
|
`push_private_key` BINARY(128) NOT NULL,
|
|
|
|
`push_public_key` BINARY(128) NOT NULL,
|
2019-09-10 04:41:16 +00:00
|
|
|
`push_secret` BINARY(16),
|
2019-09-17 08:24:23 +00:00
|
|
|
`instance_type` VARCHAR(64) NOT NULL DEFAULT 'Mastodon',
|
2019-09-03 04:17:50 +00:00
|
|
|
`enabled` BOOLEAN DEFAULT 0,
|
2019-08-31 10:34:45 +00:00
|
|
|
`replies_enabled` BOOLEAN DEFAULT 1,
|
2019-08-31 10:38:40 +00:00
|
|
|
`post_frequency` SMALLINT UNSIGNED DEFAULT 30,
|
2019-08-31 10:34:45 +00:00
|
|
|
`content_warning` VARCHAR(128),
|
2019-08-31 10:38:40 +00:00
|
|
|
`length` SMALLINT UNSIGNED DEFAULT 500,
|
2019-09-09 09:40:22 +00:00
|
|
|
`fake_mentions` ENUM('always', 'middle', 'never') DEFAULT 'middle',
|
2019-08-31 10:34:45 +00:00
|
|
|
`fake_mentions_full` BOOLEAN DEFAULT 0,
|
2019-09-09 09:51:45 +00:00
|
|
|
`post_privacy` ENUM('public', 'unlisted', 'private') DEFAULT 'unlisted',
|
2019-08-31 10:34:45 +00:00
|
|
|
`learn_from_cw` BOOLEAN DEFAULT 0,
|
2019-09-11 10:43:33 +00:00
|
|
|
`last_post` DATETIME DEFAULT CURRENT_TIMESTAMP(),
|
2019-09-01 05:06:25 +00:00
|
|
|
`icon` VARCHAR(512),
|
2019-09-11 10:43:33 +00:00
|
|
|
`icon_update_time` DATETIME DEFAULT '1000-01-01 00:00:00',
|
2019-09-01 06:01:53 +00:00
|
|
|
FOREIGN KEY (`user_id`) REFERENCES users(id) ON DELETE CASCADE,
|
2019-08-31 10:34:45 +00:00
|
|
|
FOREIGN KEY (`credentials_id`) REFERENCES credentials(id) ON DELETE CASCADE
|
2019-09-01 06:02:25 +00:00
|
|
|
) ENGINE=INNODB;
|
2019-09-02 03:31:29 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS `fedi_accounts` (
|
2019-09-01 10:01:27 +00:00
|
|
|
`handle` VARCHAR(128) PRIMARY KEY,
|
2019-08-31 14:08:58 +00:00
|
|
|
`outbox` VARCHAR(256),
|
2019-09-02 10:07:16 +00:00
|
|
|
`credentials_id` INT,
|
2019-09-01 05:06:25 +00:00
|
|
|
`icon` VARCHAR(512),
|
|
|
|
`icon_update_time` DATETIME DEFAULT 0,
|
2019-08-31 10:34:45 +00:00
|
|
|
FOREIGN KEY (`credentials_id`) REFERENCES credentials(id) ON DELETE CASCADE
|
2019-09-01 06:02:25 +00:00
|
|
|
) ENGINE=INNODB;
|
2019-09-02 03:31:29 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS `bot_learned_accounts` (
|
2019-09-02 06:36:42 +00:00
|
|
|
`bot_id` VARCHAR(128) NOT NULL,
|
2019-09-02 03:31:29 +00:00
|
|
|
`fedi_id` VARCHAR(128) NOT NULL,
|
2019-09-02 10:14:03 +00:00
|
|
|
`enabled` BOOLEAN DEFAULT 1,
|
2019-09-02 06:36:42 +00:00
|
|
|
FOREIGN KEY (`bot_id`) REFERENCES bots(handle) ON DELETE CASCADE,
|
2019-09-02 03:31:29 +00:00
|
|
|
FOREIGN KEY (`fedi_id`) REFERENCES fedi_accounts(handle) ON DELETE CASCADE
|
|
|
|
) ENGINE=INNODB;
|
2019-08-31 10:34:45 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS `posts` (
|
|
|
|
`id` BIGINT AUTO_INCREMENT PRIMARY KEY,
|
2019-09-01 10:01:27 +00:00
|
|
|
`fedi_id` VARCHAR(128),
|
2019-08-31 10:34:45 +00:00
|
|
|
`post_id` VARCHAR(64) NOT NULL,
|
2019-09-01 05:57:42 +00:00
|
|
|
`content` TEXT NOT NULL,
|
2019-09-01 10:01:27 +00:00
|
|
|
`cw` BOOLEAN NOT NULL,
|
2019-09-02 05:57:11 +00:00
|
|
|
FOREIGN KEY (`fedi_id`) REFERENCES fedi_accounts(handle) ON DELETE CASCADE
|
2019-09-01 06:02:25 +00:00
|
|
|
) ENGINE=INNODB;
|
2019-09-01 03:59:44 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS `word_blacklist` (
|
|
|
|
`id` INT AUTO_INCREMENT PRIMARY KEY,
|
2019-09-02 06:36:42 +00:00
|
|
|
`bot_id` VARCHAR(128) NOT NULL,
|
2019-09-01 03:59:44 +00:00
|
|
|
`phrase` VARCHAR(128) NOT NULL,
|
2019-09-01 06:10:30 +00:00
|
|
|
`whole_word` BOOLEAN NOT NULL,
|
2019-09-02 06:36:42 +00:00
|
|
|
FOREIGN KEY (`bot_id`) REFERENCES bots(handle) ON DELETE CASCADE
|
2019-09-01 06:02:25 +00:00
|
|
|
) ENGINE=INNODB;
|
2019-09-01 05:03:18 +00:00
|
|
|
CREATE TABLE IF NOT EXISTS `contact_history` (
|
2019-09-01 09:53:38 +00:00
|
|
|
`user_id` INT NOT NULL,
|
2019-09-01 05:03:18 +00:00
|
|
|
`fetch` BOOLEAN DEFAULT 0,
|
|
|
|
`submit` BOOLEAN DEFAULT 0,
|
|
|
|
`generation` BOOLEAN DEFAULT 0,
|
2019-09-01 06:10:30 +00:00
|
|
|
`reply` BOOLEAN DEFAULT 0,
|
|
|
|
FOREIGN KEY (`user_id`) REFERENCES users(id) ON DELETE CASCADE
|
2019-09-01 06:02:25 +00:00
|
|
|
) ENGINE=INNODB;
|