2023-09-29 09:15:54 +08:00
|
|
|
-- drop all tables first
|
|
|
|
DROP TABLE IF EXISTS `migration_history`;
|
|
|
|
DROP TABLE IF EXISTS `system_setting`;
|
|
|
|
DROP TABLE IF EXISTS `user`;
|
|
|
|
DROP TABLE IF EXISTS `user_setting`;
|
|
|
|
DROP TABLE IF EXISTS `memo`;
|
|
|
|
DROP TABLE IF EXISTS `memo_organizer`;
|
|
|
|
DROP TABLE IF EXISTS `memo_relation`;
|
|
|
|
DROP TABLE IF EXISTS `resource`;
|
|
|
|
DROP TABLE IF EXISTS `tag`;
|
|
|
|
DROP TABLE IF EXISTS `activity`;
|
|
|
|
DROP TABLE IF EXISTS `storage`;
|
|
|
|
DROP TABLE IF EXISTS `idp`;
|
2023-10-27 01:18:00 +08:00
|
|
|
DROP TABLE IF EXISTS `inbox`;
|
2023-12-09 12:05:45 +08:00
|
|
|
DROP TABLE IF EXISTS `webhook`;
|
2023-09-29 09:15:54 +08:00
|
|
|
|
|
|
|
-- migration_history
|
|
|
|
CREATE TABLE `migration_history` (
|
2023-12-09 12:05:45 +08:00
|
|
|
`version` VARCHAR(256) NOT NULL PRIMARY KEY,
|
2023-09-29 12:47:49 +08:00
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
-- system_setting
|
|
|
|
CREATE TABLE `system_setting` (
|
2023-12-09 12:05:45 +08:00
|
|
|
`name` VARCHAR(256) NOT NULL PRIMARY KEY,
|
2023-10-31 10:23:15 +08:00
|
|
|
`value` LONGTEXT NOT NULL,
|
2023-09-29 12:47:49 +08:00
|
|
|
`description` TEXT NOT NULL
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
-- user
|
|
|
|
CREATE TABLE `user` (
|
2023-09-29 12:47:49 +08:00
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
2023-09-29 09:15:54 +08:00
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
`updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2023-12-09 12:05:45 +08:00
|
|
|
`row_status` VARCHAR(256) NOT NULL DEFAULT 'NORMAL',
|
|
|
|
`username` VARCHAR(256) NOT NULL UNIQUE,
|
|
|
|
`role` VARCHAR(256) NOT NULL DEFAULT 'USER',
|
|
|
|
`email` VARCHAR(256) NOT NULL DEFAULT '',
|
|
|
|
`nickname` VARCHAR(256) NOT NULL DEFAULT '',
|
|
|
|
`password_hash` VARCHAR(256) NOT NULL,
|
2023-10-31 10:23:15 +08:00
|
|
|
`avatar_url` LONGTEXT NOT NULL
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
-- user_setting
|
|
|
|
CREATE TABLE `user_setting` (
|
2023-09-29 12:47:49 +08:00
|
|
|
`user_id` INT NOT NULL,
|
2023-12-09 12:05:45 +08:00
|
|
|
`key` VARCHAR(256) NOT NULL,
|
2023-10-31 10:23:15 +08:00
|
|
|
`value` LONGTEXT NOT NULL,
|
2023-09-29 12:47:49 +08:00
|
|
|
UNIQUE(`user_id`,`key`)
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
-- memo
|
|
|
|
CREATE TABLE `memo` (
|
2023-09-29 12:47:49 +08:00
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
`creator_id` INT NOT NULL,
|
2023-09-29 09:15:54 +08:00
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
`updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2023-12-09 12:05:45 +08:00
|
|
|
`row_status` VARCHAR(256) NOT NULL DEFAULT 'NORMAL',
|
2023-09-29 12:47:49 +08:00
|
|
|
`content` TEXT NOT NULL,
|
2023-12-09 12:05:45 +08:00
|
|
|
`visibility` VARCHAR(256) NOT NULL DEFAULT 'PRIVATE'
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
-- memo_organizer
|
|
|
|
CREATE TABLE `memo_organizer` (
|
2023-09-29 12:47:49 +08:00
|
|
|
`memo_id` INT NOT NULL,
|
|
|
|
`user_id` INT NOT NULL,
|
|
|
|
`pinned` INT NOT NULL DEFAULT '0',
|
|
|
|
UNIQUE(`memo_id`,`user_id`)
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
-- memo_relation
|
|
|
|
CREATE TABLE `memo_relation` (
|
2023-09-29 12:47:49 +08:00
|
|
|
`memo_id` INT NOT NULL,
|
|
|
|
`related_memo_id` INT NOT NULL,
|
|
|
|
`type` VARCHAR(256) NOT NULL,
|
|
|
|
UNIQUE(`memo_id`,`related_memo_id`,`type`)
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
-- resource
|
|
|
|
CREATE TABLE `resource` (
|
2023-09-29 12:47:49 +08:00
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
`creator_id` INT NOT NULL,
|
2023-09-29 09:15:54 +08:00
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
`updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2023-09-29 12:47:49 +08:00
|
|
|
`filename` TEXT NOT NULL,
|
2023-10-07 22:56:12 +08:00
|
|
|
`blob` MEDIUMBLOB,
|
2023-09-29 12:47:49 +08:00
|
|
|
`external_link` TEXT NOT NULL,
|
2023-12-09 12:05:45 +08:00
|
|
|
`type` VARCHAR(256) NOT NULL DEFAULT '',
|
2023-09-29 12:47:49 +08:00
|
|
|
`size` INT NOT NULL DEFAULT '0',
|
2023-12-09 12:05:45 +08:00
|
|
|
`internal_path` VARCHAR(256) NOT NULL DEFAULT '',
|
2023-09-29 12:47:49 +08:00
|
|
|
`memo_id` INT DEFAULT NULL
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
-- tag
|
|
|
|
CREATE TABLE `tag` (
|
2023-12-09 12:05:45 +08:00
|
|
|
`name` VARCHAR(256) NOT NULL,
|
2023-09-29 12:47:49 +08:00
|
|
|
`creator_id` INT NOT NULL,
|
|
|
|
UNIQUE(`name`,`creator_id`)
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
-- activity
|
|
|
|
CREATE TABLE `activity` (
|
2023-09-29 12:47:49 +08:00
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
`creator_id` INT NOT NULL,
|
2023-09-29 09:15:54 +08:00
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2023-12-09 12:05:45 +08:00
|
|
|
`type` VARCHAR(256) NOT NULL DEFAULT '',
|
|
|
|
`level` VARCHAR(256) NOT NULL DEFAULT 'INFO',
|
2023-09-29 12:47:49 +08:00
|
|
|
`payload` TEXT NOT NULL
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
-- storage
|
|
|
|
CREATE TABLE `storage` (
|
2023-09-29 12:47:49 +08:00
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
`name` VARCHAR(256) NOT NULL,
|
|
|
|
`type` VARCHAR(256) NOT NULL,
|
|
|
|
`config` TEXT NOT NULL
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
-- idp
|
|
|
|
CREATE TABLE `idp` (
|
2023-09-29 12:47:49 +08:00
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
`name` TEXT NOT NULL,
|
|
|
|
`type` TEXT NOT NULL,
|
|
|
|
`identifier_filter` VARCHAR(256) NOT NULL DEFAULT '',
|
|
|
|
`config` TEXT NOT NULL
|
2023-09-29 09:15:54 +08:00
|
|
|
);
|
2023-10-27 01:18:00 +08:00
|
|
|
|
|
|
|
-- inbox
|
|
|
|
CREATE TABLE `inbox` (
|
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
`sender_id` INT NOT NULL,
|
|
|
|
`receiver_id` INT NOT NULL,
|
|
|
|
`status` TEXT NOT NULL,
|
2023-11-05 15:38:45 +08:00
|
|
|
`message` TEXT NOT NULL
|
2023-10-27 01:18:00 +08:00
|
|
|
);
|
2023-11-24 22:45:38 +08:00
|
|
|
|
|
|
|
-- webhook
|
|
|
|
CREATE TABLE `webhook` (
|
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
`updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2023-12-09 12:05:45 +08:00
|
|
|
`row_status` VARCHAR(256) NOT NULL DEFAULT 'NORMAL',
|
2023-11-24 22:45:38 +08:00
|
|
|
`creator_id` INT NOT NULL,
|
|
|
|
`name` TEXT NOT NULL,
|
|
|
|
`url` TEXT NOT NULL
|
|
|
|
);
|