2023-09-29 04:15:54 +03: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`;
|
|
|
|
|
|
|
|
-- migration_history
|
|
|
|
CREATE TABLE `migration_history` (
|
2023-09-29 07:47:49 +03:00
|
|
|
`version` VARCHAR(255) NOT NULL PRIMARY KEY,
|
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
2023-09-29 04:15:54 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
-- system_setting
|
|
|
|
CREATE TABLE `system_setting` (
|
2023-09-29 07:47:49 +03:00
|
|
|
`name` VARCHAR(255) NOT NULL PRIMARY KEY,
|
|
|
|
`value` TEXT NOT NULL,
|
|
|
|
`description` TEXT NOT NULL
|
2023-09-29 04:15:54 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
-- user
|
|
|
|
CREATE TABLE `user` (
|
2023-09-29 07:47:49 +03:00
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
2023-09-29 04:15:54 +03:00
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
`updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2023-09-29 07:47:49 +03:00
|
|
|
`row_status` VARCHAR(255) NOT NULL DEFAULT 'NORMAL',
|
|
|
|
`username` VARCHAR(255) NOT NULL UNIQUE,
|
|
|
|
`role` VARCHAR(255) NOT NULL DEFAULT 'USER',
|
|
|
|
`email` VARCHAR(255) NOT NULL DEFAULT '',
|
|
|
|
`nickname` VARCHAR(255) NOT NULL DEFAULT '',
|
|
|
|
`password_hash` VARCHAR(255) NOT NULL,
|
|
|
|
`avatar_url` TEXT NOT NULL
|
2023-09-29 04:15:54 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
-- user_setting
|
|
|
|
CREATE TABLE `user_setting` (
|
2023-09-29 07:47:49 +03:00
|
|
|
`user_id` INT NOT NULL,
|
|
|
|
`key` VARCHAR(255) NOT NULL,
|
|
|
|
`value` TEXT NOT NULL,
|
|
|
|
UNIQUE(`user_id`,`key`)
|
2023-09-29 04:15:54 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
-- memo
|
|
|
|
CREATE TABLE `memo` (
|
2023-09-29 07:47:49 +03:00
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
`creator_id` INT NOT NULL,
|
2023-09-29 04:15:54 +03:00
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
`updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2023-09-29 07:47:49 +03:00
|
|
|
`row_status` VARCHAR(255) NOT NULL DEFAULT 'NORMAL',
|
|
|
|
`content` TEXT NOT NULL,
|
|
|
|
`visibility` VARCHAR(255) NOT NULL DEFAULT 'PRIVATE'
|
2023-09-29 04:15:54 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
-- memo_organizer
|
|
|
|
CREATE TABLE `memo_organizer` (
|
2023-09-29 07:47:49 +03: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 04:15:54 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
-- memo_relation
|
|
|
|
CREATE TABLE `memo_relation` (
|
2023-09-29 07:47:49 +03: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 04:15:54 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
-- resource
|
|
|
|
CREATE TABLE `resource` (
|
2023-09-29 07:47:49 +03:00
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
`creator_id` INT NOT NULL,
|
2023-09-29 04:15:54 +03:00
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
|
|
`updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2023-09-29 07:47:49 +03:00
|
|
|
`filename` TEXT NOT NULL,
|
2023-10-07 17:56:12 +03:00
|
|
|
`blob` MEDIUMBLOB,
|
2023-09-29 07:47:49 +03:00
|
|
|
`external_link` TEXT NOT NULL,
|
|
|
|
`type` VARCHAR(255) NOT NULL DEFAULT '',
|
|
|
|
`size` INT NOT NULL DEFAULT '0',
|
2023-10-05 18:11:29 +03:00
|
|
|
`internal_path` VARCHAR(255) NOT NULL DEFAULT '',
|
2023-09-29 07:47:49 +03:00
|
|
|
`memo_id` INT DEFAULT NULL
|
2023-09-29 04:15:54 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
-- tag
|
|
|
|
CREATE TABLE `tag` (
|
2023-09-29 07:47:49 +03:00
|
|
|
`name` VARCHAR(255) NOT NULL,
|
|
|
|
`creator_id` INT NOT NULL,
|
|
|
|
UNIQUE(`name`,`creator_id`)
|
2023-09-29 04:15:54 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
-- activity
|
|
|
|
CREATE TABLE `activity` (
|
2023-09-29 07:47:49 +03:00
|
|
|
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
|
|
|
|
`creator_id` INT NOT NULL,
|
2023-09-29 04:15:54 +03:00
|
|
|
`created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
2023-09-29 07:47:49 +03:00
|
|
|
`type` VARCHAR(255) NOT NULL DEFAULT '',
|
|
|
|
`level` VARCHAR(255) NOT NULL DEFAULT 'INFO',
|
|
|
|
`payload` TEXT NOT NULL
|
2023-09-29 04:15:54 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
-- storage
|
|
|
|
CREATE TABLE `storage` (
|
2023-09-29 07:47:49 +03: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 04:15:54 +03:00
|
|
|
);
|
|
|
|
|
|
|
|
-- idp
|
|
|
|
CREATE TABLE `idp` (
|
2023-09-29 07:47:49 +03: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 04:15:54 +03:00
|
|
|
);
|