diff --git a/store/migration/mysql/prod/0.17/00__inbox.sql b/store/migration/mysql/0.17/00__inbox.sql similarity index 100% rename from store/migration/mysql/prod/0.17/00__inbox.sql rename to store/migration/mysql/0.17/00__inbox.sql diff --git a/store/migration/mysql/prod/0.17/01__delete_activity.sql b/store/migration/mysql/0.17/01__delete_activity.sql similarity index 100% rename from store/migration/mysql/prod/0.17/01__delete_activity.sql rename to store/migration/mysql/0.17/01__delete_activity.sql diff --git a/store/migration/mysql/prod/0.18/00__extend_text.sql b/store/migration/mysql/0.18/00__extend_text.sql similarity index 100% rename from store/migration/mysql/prod/0.18/00__extend_text.sql rename to store/migration/mysql/0.18/00__extend_text.sql diff --git a/store/migration/mysql/prod/0.18/01__webhook.sql b/store/migration/mysql/0.18/01__webhook.sql similarity index 100% rename from store/migration/mysql/prod/0.18/01__webhook.sql rename to store/migration/mysql/0.18/01__webhook.sql diff --git a/store/migration/mysql/prod/0.18/02__user_setting.sql b/store/migration/mysql/0.18/02__user_setting.sql similarity index 100% rename from store/migration/mysql/prod/0.18/02__user_setting.sql rename to store/migration/mysql/0.18/02__user_setting.sql diff --git a/store/migration/mysql/prod/0.19/00__add_resource_name.sql b/store/migration/mysql/0.19/00__add_resource_name.sql similarity index 100% rename from store/migration/mysql/prod/0.19/00__add_resource_name.sql rename to store/migration/mysql/0.19/00__add_resource_name.sql diff --git a/store/migration/mysql/prod/0.20/00__reaction.sql b/store/migration/mysql/0.20/00__reaction.sql similarity index 100% rename from store/migration/mysql/prod/0.20/00__reaction.sql rename to store/migration/mysql/0.20/00__reaction.sql diff --git a/store/migration/mysql/prod/0.21/00__user_description.sql b/store/migration/mysql/0.21/00__user_description.sql similarity index 100% rename from store/migration/mysql/prod/0.21/00__user_description.sql rename to store/migration/mysql/0.21/00__user_description.sql diff --git a/store/migration/mysql/prod/0.21/01__rename_uid.sql b/store/migration/mysql/0.21/01__rename_uid.sql similarity index 100% rename from store/migration/mysql/prod/0.21/01__rename_uid.sql rename to store/migration/mysql/0.21/01__rename_uid.sql diff --git a/store/migration/mysql/prod/0.22/00__resource_storage_type.sql b/store/migration/mysql/0.22/00__resource_storage_type.sql similarity index 100% rename from store/migration/mysql/prod/0.22/00__resource_storage_type.sql rename to store/migration/mysql/0.22/00__resource_storage_type.sql diff --git a/store/migration/mysql/prod/0.22/01__memo_tags.sql b/store/migration/mysql/0.22/01__memo_tags.sql similarity index 100% rename from store/migration/mysql/prod/0.22/01__memo_tags.sql rename to store/migration/mysql/0.22/01__memo_tags.sql diff --git a/store/migration/mysql/prod/0.22/02__memo_payload.sql b/store/migration/mysql/0.22/02__memo_payload.sql similarity index 100% rename from store/migration/mysql/prod/0.22/02__memo_payload.sql rename to store/migration/mysql/0.22/02__memo_payload.sql diff --git a/store/migration/mysql/prod/0.22/03__drop_tag.sql b/store/migration/mysql/0.22/03__drop_tag.sql similarity index 100% rename from store/migration/mysql/prod/0.22/03__drop_tag.sql rename to store/migration/mysql/0.22/03__drop_tag.sql diff --git a/store/migration/mysql/prod/0.23/00__reactions.sql b/store/migration/mysql/0.23/00__reactions.sql similarity index 100% rename from store/migration/mysql/prod/0.23/00__reactions.sql rename to store/migration/mysql/0.23/00__reactions.sql diff --git a/store/migration/mysql/prod/LATEST.sql b/store/migration/mysql/LATEST.sql similarity index 100% rename from store/migration/mysql/prod/LATEST.sql rename to store/migration/mysql/LATEST.sql diff --git a/store/migration/mysql/dev/LATEST.sql b/store/migration/mysql/dev/LATEST.sql deleted file mode 100644 index 347736ae..00000000 --- a/store/migration/mysql/dev/LATEST.sql +++ /dev/null @@ -1,131 +0,0 @@ --- migration_history -CREATE TABLE `migration_history` ( - `version` VARCHAR(256) NOT NULL PRIMARY KEY, - `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP -); - --- system_setting -CREATE TABLE `system_setting` ( - `name` VARCHAR(256) NOT NULL PRIMARY KEY, - `value` LONGTEXT NOT NULL, - `description` TEXT NOT NULL -); - --- user -CREATE TABLE `user` ( - `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `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, - `avatar_url` LONGTEXT NOT NULL, - `description` VARCHAR(256) NOT NULL DEFAULT '' -); - --- user_setting -CREATE TABLE `user_setting` ( - `user_id` INT NOT NULL, - `key` VARCHAR(256) NOT NULL, - `value` LONGTEXT NOT NULL, - UNIQUE(`user_id`,`key`) -); - --- memo -CREATE TABLE `memo` ( - `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - `uid` VARCHAR(256) NOT NULL UNIQUE, - `creator_id` INT NOT NULL, - `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `row_status` VARCHAR(256) NOT NULL DEFAULT 'NORMAL', - `content` TEXT NOT NULL, - `visibility` VARCHAR(256) NOT NULL DEFAULT 'PRIVATE', - `payload` JSON NOT NULL -); - --- memo_organizer -CREATE TABLE `memo_organizer` ( - `memo_id` INT NOT NULL, - `user_id` INT NOT NULL, - `pinned` INT NOT NULL DEFAULT '0', - UNIQUE(`memo_id`,`user_id`) -); - --- memo_relation -CREATE TABLE `memo_relation` ( - `memo_id` INT NOT NULL, - `related_memo_id` INT NOT NULL, - `type` VARCHAR(256) NOT NULL, - UNIQUE(`memo_id`,`related_memo_id`,`type`) -); - --- resource -CREATE TABLE `resource` ( - `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - `uid` VARCHAR(256) NOT NULL UNIQUE, - `creator_id` INT NOT NULL, - `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `updated_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `filename` TEXT NOT NULL, - `blob` MEDIUMBLOB, - `type` VARCHAR(256) NOT NULL DEFAULT '', - `size` INT NOT NULL DEFAULT '0', - `memo_id` INT DEFAULT NULL, - `storage_type` VARCHAR(256) NOT NULL DEFAULT '', - `reference` VARCHAR(256) NOT NULL DEFAULT '', - `payload` TEXT NOT NULL -); - --- activity -CREATE TABLE `activity` ( - `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - `creator_id` INT NOT NULL, - `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `type` VARCHAR(256) NOT NULL DEFAULT '', - `level` VARCHAR(256) NOT NULL DEFAULT 'INFO', - `payload` TEXT NOT NULL -); - --- idp -CREATE TABLE `idp` ( - `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 -); - --- 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, - `message` TEXT NOT NULL -); - --- 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, - `row_status` VARCHAR(256) NOT NULL DEFAULT 'NORMAL', - `creator_id` INT NOT NULL, - `name` TEXT NOT NULL, - `url` TEXT NOT NULL -); - --- reaction -CREATE TABLE `reaction` ( - `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, - `created_ts` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `creator_id` INT NOT NULL, - `content_id` VARCHAR(256) NOT NULL, - `reaction_type` VARCHAR(256) NOT NULL, - UNIQUE(`creator_id`,`content_id`,`reaction_type`) -); diff --git a/store/migration/postgres/prod/0.19/00__add_resource_name.sql b/store/migration/postgres/0.19/00__add_resource_name.sql similarity index 100% rename from store/migration/postgres/prod/0.19/00__add_resource_name.sql rename to store/migration/postgres/0.19/00__add_resource_name.sql diff --git a/store/migration/postgres/prod/0.20/00__reaction.sql b/store/migration/postgres/0.20/00__reaction.sql similarity index 100% rename from store/migration/postgres/prod/0.20/00__reaction.sql rename to store/migration/postgres/0.20/00__reaction.sql diff --git a/store/migration/postgres/prod/0.21/00__user_description.sql b/store/migration/postgres/0.21/00__user_description.sql similarity index 100% rename from store/migration/postgres/prod/0.21/00__user_description.sql rename to store/migration/postgres/0.21/00__user_description.sql diff --git a/store/migration/postgres/prod/0.21/01__rename_uid.sql b/store/migration/postgres/0.21/01__rename_uid.sql similarity index 100% rename from store/migration/postgres/prod/0.21/01__rename_uid.sql rename to store/migration/postgres/0.21/01__rename_uid.sql diff --git a/store/migration/postgres/prod/0.22/00__resource_storage_type.sql b/store/migration/postgres/0.22/00__resource_storage_type.sql similarity index 100% rename from store/migration/postgres/prod/0.22/00__resource_storage_type.sql rename to store/migration/postgres/0.22/00__resource_storage_type.sql diff --git a/store/migration/postgres/prod/0.22/01__memo_tags.sql b/store/migration/postgres/0.22/01__memo_tags.sql similarity index 100% rename from store/migration/postgres/prod/0.22/01__memo_tags.sql rename to store/migration/postgres/0.22/01__memo_tags.sql diff --git a/store/migration/postgres/prod/0.22/02__memo_payload.sql b/store/migration/postgres/0.22/02__memo_payload.sql similarity index 100% rename from store/migration/postgres/prod/0.22/02__memo_payload.sql rename to store/migration/postgres/0.22/02__memo_payload.sql diff --git a/store/migration/postgres/prod/0.22/03__drop_tag.sql b/store/migration/postgres/0.22/03__drop_tag.sql similarity index 100% rename from store/migration/postgres/prod/0.22/03__drop_tag.sql rename to store/migration/postgres/0.22/03__drop_tag.sql diff --git a/store/migration/postgres/prod/0.23/00__reactions.sql b/store/migration/postgres/0.23/00__reactions.sql similarity index 100% rename from store/migration/postgres/prod/0.23/00__reactions.sql rename to store/migration/postgres/0.23/00__reactions.sql diff --git a/store/migration/postgres/prod/LATEST.sql b/store/migration/postgres/LATEST.sql similarity index 100% rename from store/migration/postgres/prod/LATEST.sql rename to store/migration/postgres/LATEST.sql diff --git a/store/migration/postgres/dev/LATEST.sql b/store/migration/postgres/dev/LATEST.sql deleted file mode 100644 index f37025b5..00000000 --- a/store/migration/postgres/dev/LATEST.sql +++ /dev/null @@ -1,131 +0,0 @@ --- migration_history -CREATE TABLE migration_history ( - version TEXT NOT NULL PRIMARY KEY, - created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()) -); - --- system_setting -CREATE TABLE system_setting ( - name TEXT NOT NULL PRIMARY KEY, - value TEXT NOT NULL, - description TEXT NOT NULL -); - --- user -CREATE TABLE "user" ( - id SERIAL PRIMARY KEY, - created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), - updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), - row_status TEXT NOT NULL DEFAULT 'NORMAL', - username TEXT NOT NULL UNIQUE, - role TEXT NOT NULL DEFAULT 'USER', - email TEXT NOT NULL DEFAULT '', - nickname TEXT NOT NULL DEFAULT '', - password_hash TEXT NOT NULL, - avatar_url TEXT NOT NULL, - description TEXT NOT NULL DEFAULT '' -); - --- user_setting -CREATE TABLE user_setting ( - user_id INTEGER NOT NULL, - key TEXT NOT NULL, - value TEXT NOT NULL, - UNIQUE(user_id, key) -); - --- memo -CREATE TABLE memo ( - id SERIAL PRIMARY KEY, - uid TEXT NOT NULL UNIQUE, - creator_id INTEGER NOT NULL, - created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), - updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), - row_status TEXT NOT NULL DEFAULT 'NORMAL', - content TEXT NOT NULL, - visibility TEXT NOT NULL DEFAULT 'PRIVATE', - payload JSONB NOT NULL DEFAULT '{}' -); - --- memo_organizer -CREATE TABLE memo_organizer ( - memo_id INTEGER NOT NULL, - user_id INTEGER NOT NULL, - pinned INTEGER NOT NULL DEFAULT 0, - UNIQUE(memo_id, user_id) -); - --- memo_relation -CREATE TABLE memo_relation ( - memo_id INTEGER NOT NULL, - related_memo_id INTEGER NOT NULL, - type TEXT NOT NULL, - UNIQUE(memo_id, related_memo_id, type) -); - --- resource -CREATE TABLE resource ( - id SERIAL PRIMARY KEY, - uid TEXT NOT NULL UNIQUE, - creator_id INTEGER NOT NULL, - created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), - updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), - filename TEXT NOT NULL, - blob BYTEA, - type TEXT NOT NULL DEFAULT '', - size INTEGER NOT NULL DEFAULT 0, - memo_id INTEGER DEFAULT NULL, - storage_type TEXT NOT NULL DEFAULT '', - reference TEXT NOT NULL DEFAULT '', - payload TEXT NOT NULL DEFAULT '{}' -); - --- activity -CREATE TABLE activity ( - id SERIAL PRIMARY KEY, - creator_id INTEGER NOT NULL, - created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), - type TEXT NOT NULL DEFAULT '', - level TEXT NOT NULL DEFAULT 'INFO', - payload JSONB NOT NULL DEFAULT '{}' -); - --- idp -CREATE TABLE idp ( - id SERIAL PRIMARY KEY, - name TEXT NOT NULL, - type TEXT NOT NULL, - identifier_filter TEXT NOT NULL DEFAULT '', - config JSONB NOT NULL DEFAULT '{}' -); - --- inbox -CREATE TABLE inbox ( - id SERIAL PRIMARY KEY, - created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), - sender_id INTEGER NOT NULL, - receiver_id INTEGER NOT NULL, - status TEXT NOT NULL, - message TEXT NOT NULL -); - --- webhook -CREATE TABLE webhook ( - id SERIAL PRIMARY KEY, - created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), - updated_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), - row_status TEXT NOT NULL DEFAULT 'NORMAL', - creator_id INTEGER NOT NULL, - name TEXT NOT NULL, - url TEXT NOT NULL -); - --- reaction -CREATE TABLE reaction ( - id SERIAL PRIMARY KEY, - created_ts BIGINT NOT NULL DEFAULT EXTRACT(EPOCH FROM NOW()), - creator_id INTEGER NOT NULL, - content_id TEXT NOT NULL, - reaction_type TEXT NOT NULL, - UNIQUE(creator_id, content_id, reaction_type) -); diff --git a/store/migration/sqlite/prod/0.10/00__activity.sql b/store/migration/sqlite/0.10/00__activity.sql similarity index 100% rename from store/migration/sqlite/prod/0.10/00__activity.sql rename to store/migration/sqlite/0.10/00__activity.sql diff --git a/store/migration/sqlite/prod/0.11/00__user_avatar.sql b/store/migration/sqlite/0.11/00__user_avatar.sql similarity index 100% rename from store/migration/sqlite/prod/0.11/00__user_avatar.sql rename to store/migration/sqlite/0.11/00__user_avatar.sql diff --git a/store/migration/sqlite/prod/0.11/01__idp.sql b/store/migration/sqlite/0.11/01__idp.sql similarity index 100% rename from store/migration/sqlite/prod/0.11/01__idp.sql rename to store/migration/sqlite/0.11/01__idp.sql diff --git a/store/migration/sqlite/prod/0.11/02__storage.sql b/store/migration/sqlite/0.11/02__storage.sql similarity index 100% rename from store/migration/sqlite/prod/0.11/02__storage.sql rename to store/migration/sqlite/0.11/02__storage.sql diff --git a/store/migration/sqlite/prod/0.12/00__user_setting.sql b/store/migration/sqlite/0.12/00__user_setting.sql similarity index 100% rename from store/migration/sqlite/prod/0.12/00__user_setting.sql rename to store/migration/sqlite/0.12/00__user_setting.sql diff --git a/store/migration/sqlite/prod/0.12/01__system_setting.sql b/store/migration/sqlite/0.12/01__system_setting.sql similarity index 100% rename from store/migration/sqlite/prod/0.12/01__system_setting.sql rename to store/migration/sqlite/0.12/01__system_setting.sql diff --git a/store/migration/sqlite/prod/0.12/03__resource_internal_path.sql b/store/migration/sqlite/0.12/03__resource_internal_path.sql similarity index 100% rename from store/migration/sqlite/prod/0.12/03__resource_internal_path.sql rename to store/migration/sqlite/0.12/03__resource_internal_path.sql diff --git a/store/migration/sqlite/prod/0.12/04__resource_public_id.sql b/store/migration/sqlite/0.12/04__resource_public_id.sql similarity index 100% rename from store/migration/sqlite/prod/0.12/04__resource_public_id.sql rename to store/migration/sqlite/0.12/04__resource_public_id.sql diff --git a/store/migration/sqlite/prod/0.13/00__memo_relation.sql b/store/migration/sqlite/0.13/00__memo_relation.sql similarity index 100% rename from store/migration/sqlite/prod/0.13/00__memo_relation.sql rename to store/migration/sqlite/0.13/00__memo_relation.sql diff --git a/store/migration/sqlite/prod/0.13/01__remove_memo_organizer_id.sql b/store/migration/sqlite/0.13/01__remove_memo_organizer_id.sql similarity index 100% rename from store/migration/sqlite/prod/0.13/01__remove_memo_organizer_id.sql rename to store/migration/sqlite/0.13/01__remove_memo_organizer_id.sql diff --git a/store/migration/sqlite/prod/0.14/00__drop_resource_public_id.sql b/store/migration/sqlite/0.14/00__drop_resource_public_id.sql similarity index 100% rename from store/migration/sqlite/prod/0.14/00__drop_resource_public_id.sql rename to store/migration/sqlite/0.14/00__drop_resource_public_id.sql diff --git a/store/migration/sqlite/prod/0.14/01__create_indexes.sql b/store/migration/sqlite/0.14/01__create_indexes.sql similarity index 100% rename from store/migration/sqlite/prod/0.14/01__create_indexes.sql rename to store/migration/sqlite/0.14/01__create_indexes.sql diff --git a/store/migration/sqlite/prod/0.15/00__drop_user_open_id.sql b/store/migration/sqlite/0.15/00__drop_user_open_id.sql similarity index 100% rename from store/migration/sqlite/prod/0.15/00__drop_user_open_id.sql rename to store/migration/sqlite/0.15/00__drop_user_open_id.sql diff --git a/store/migration/sqlite/prod/0.16/00__add_memo_id_to_resource.sql b/store/migration/sqlite/0.16/00__add_memo_id_to_resource.sql similarity index 100% rename from store/migration/sqlite/prod/0.16/00__add_memo_id_to_resource.sql rename to store/migration/sqlite/0.16/00__add_memo_id_to_resource.sql diff --git a/store/migration/sqlite/prod/0.16/01__drop_shortcut_table.sql b/store/migration/sqlite/0.16/01__drop_shortcut_table.sql similarity index 100% rename from store/migration/sqlite/prod/0.16/01__drop_shortcut_table.sql rename to store/migration/sqlite/0.16/01__drop_shortcut_table.sql diff --git a/store/migration/sqlite/prod/0.17/00__inbox.sql b/store/migration/sqlite/0.17/00__inbox.sql similarity index 100% rename from store/migration/sqlite/prod/0.17/00__inbox.sql rename to store/migration/sqlite/0.17/00__inbox.sql diff --git a/store/migration/sqlite/prod/0.17/01__delete_activities.sql b/store/migration/sqlite/0.17/01__delete_activities.sql similarity index 100% rename from store/migration/sqlite/prod/0.17/01__delete_activities.sql rename to store/migration/sqlite/0.17/01__delete_activities.sql diff --git a/store/migration/sqlite/prod/0.18/00__webhook.sql b/store/migration/sqlite/0.18/00__webhook.sql similarity index 100% rename from store/migration/sqlite/prod/0.18/00__webhook.sql rename to store/migration/sqlite/0.18/00__webhook.sql diff --git a/store/migration/sqlite/prod/0.18/01__user_setting.sql b/store/migration/sqlite/0.18/01__user_setting.sql similarity index 100% rename from store/migration/sqlite/prod/0.18/01__user_setting.sql rename to store/migration/sqlite/0.18/01__user_setting.sql diff --git a/store/migration/sqlite/prod/0.19/00__add_resource_name.sql b/store/migration/sqlite/0.19/00__add_resource_name.sql similarity index 100% rename from store/migration/sqlite/prod/0.19/00__add_resource_name.sql rename to store/migration/sqlite/0.19/00__add_resource_name.sql diff --git a/store/migration/sqlite/prod/0.2/00__user_role.sql b/store/migration/sqlite/0.2/00__user_role.sql similarity index 100% rename from store/migration/sqlite/prod/0.2/00__user_role.sql rename to store/migration/sqlite/0.2/00__user_role.sql diff --git a/store/migration/sqlite/prod/0.2/01__memo_visibility.sql b/store/migration/sqlite/0.2/01__memo_visibility.sql similarity index 100% rename from store/migration/sqlite/prod/0.2/01__memo_visibility.sql rename to store/migration/sqlite/0.2/01__memo_visibility.sql diff --git a/store/migration/sqlite/prod/0.20/00__reaction.sql b/store/migration/sqlite/0.20/00__reaction.sql similarity index 100% rename from store/migration/sqlite/prod/0.20/00__reaction.sql rename to store/migration/sqlite/0.20/00__reaction.sql diff --git a/store/migration/sqlite/prod/0.21/00__user_description.sql b/store/migration/sqlite/0.21/00__user_description.sql similarity index 100% rename from store/migration/sqlite/prod/0.21/00__user_description.sql rename to store/migration/sqlite/0.21/00__user_description.sql diff --git a/store/migration/sqlite/prod/0.21/01__rename_uid.sql b/store/migration/sqlite/0.21/01__rename_uid.sql similarity index 100% rename from store/migration/sqlite/prod/0.21/01__rename_uid.sql rename to store/migration/sqlite/0.21/01__rename_uid.sql diff --git a/store/migration/sqlite/prod/0.22/00__resource_storage_type.sql b/store/migration/sqlite/0.22/00__resource_storage_type.sql similarity index 100% rename from store/migration/sqlite/prod/0.22/00__resource_storage_type.sql rename to store/migration/sqlite/0.22/00__resource_storage_type.sql diff --git a/store/migration/sqlite/prod/0.22/01__memo_tags.sql b/store/migration/sqlite/0.22/01__memo_tags.sql similarity index 100% rename from store/migration/sqlite/prod/0.22/01__memo_tags.sql rename to store/migration/sqlite/0.22/01__memo_tags.sql diff --git a/store/migration/sqlite/prod/0.22/02__memo_payload.sql b/store/migration/sqlite/0.22/02__memo_payload.sql similarity index 100% rename from store/migration/sqlite/prod/0.22/02__memo_payload.sql rename to store/migration/sqlite/0.22/02__memo_payload.sql diff --git a/store/migration/sqlite/prod/0.22/03__drop_tag.sql b/store/migration/sqlite/0.22/03__drop_tag.sql similarity index 100% rename from store/migration/sqlite/prod/0.22/03__drop_tag.sql rename to store/migration/sqlite/0.22/03__drop_tag.sql diff --git a/store/migration/sqlite/prod/0.23/00__reactions.sql b/store/migration/sqlite/0.23/00__reactions.sql similarity index 100% rename from store/migration/sqlite/prod/0.23/00__reactions.sql rename to store/migration/sqlite/0.23/00__reactions.sql diff --git a/store/migration/sqlite/0.24/00__memo.sql b/store/migration/sqlite/0.24/00__memo.sql new file mode 100644 index 00000000..9351e4cd --- /dev/null +++ b/store/migration/sqlite/0.24/00__memo.sql @@ -0,0 +1,15 @@ +-- Drop deprecated tags column. +ALTER TABLE memo DROP COLUMN tags; + +-- Remove deprecated indexes. +DROP INDEX IF EXISTS idx_memo_tags; +DROP INDEX IF EXISTS idx_memo_content; +DROP INDEX IF EXISTS idx_memo_visibility; + +-- Add pinned column. +ALTER TABLE memo ADD COLUMN pinned INTEGER NOT NULL CHECK (pinned IN (0, 1)) DEFAULT 0; + +-- Update pinned column from memo_organizer. +UPDATE memo +SET pinned = 1 +WHERE EXISTS (SELECT 1 FROM memo_organizer WHERE memo_organizer.memo_id = memo.id AND memo_organizer.pinned = 1); diff --git a/store/migration/sqlite/prod/0.3/00__memo_visibility_protected.sql b/store/migration/sqlite/0.3/00__memo_visibility_protected.sql similarity index 100% rename from store/migration/sqlite/prod/0.3/00__memo_visibility_protected.sql rename to store/migration/sqlite/0.3/00__memo_visibility_protected.sql diff --git a/store/migration/sqlite/prod/0.4/00__user_setting.sql b/store/migration/sqlite/0.4/00__user_setting.sql similarity index 100% rename from store/migration/sqlite/prod/0.4/00__user_setting.sql rename to store/migration/sqlite/0.4/00__user_setting.sql diff --git a/store/migration/sqlite/prod/0.5/00__regenerate_foreign_keys.sql b/store/migration/sqlite/0.5/00__regenerate_foreign_keys.sql similarity index 100% rename from store/migration/sqlite/prod/0.5/00__regenerate_foreign_keys.sql rename to store/migration/sqlite/0.5/00__regenerate_foreign_keys.sql diff --git a/store/migration/sqlite/prod/0.5/01__memo_resource.sql b/store/migration/sqlite/0.5/01__memo_resource.sql similarity index 100% rename from store/migration/sqlite/prod/0.5/01__memo_resource.sql rename to store/migration/sqlite/0.5/01__memo_resource.sql diff --git a/store/migration/sqlite/prod/0.5/02__system_setting.sql b/store/migration/sqlite/0.5/02__system_setting.sql similarity index 100% rename from store/migration/sqlite/prod/0.5/02__system_setting.sql rename to store/migration/sqlite/0.5/02__system_setting.sql diff --git a/store/migration/sqlite/prod/0.5/03__resource_extermal_link.sql b/store/migration/sqlite/0.5/03__resource_extermal_link.sql similarity index 100% rename from store/migration/sqlite/prod/0.5/03__resource_extermal_link.sql rename to store/migration/sqlite/0.5/03__resource_extermal_link.sql diff --git a/store/migration/sqlite/prod/0.6/00__recreate_triggers.sql b/store/migration/sqlite/0.6/00__recreate_triggers.sql similarity index 100% rename from store/migration/sqlite/prod/0.6/00__recreate_triggers.sql rename to store/migration/sqlite/0.6/00__recreate_triggers.sql diff --git a/store/migration/sqlite/prod/0.7/00__remove_fk.sql b/store/migration/sqlite/0.7/00__remove_fk.sql similarity index 100% rename from store/migration/sqlite/prod/0.7/00__remove_fk.sql rename to store/migration/sqlite/0.7/00__remove_fk.sql diff --git a/store/migration/sqlite/prod/0.7/01__remove_triggers.sql b/store/migration/sqlite/0.7/01__remove_triggers.sql similarity index 100% rename from store/migration/sqlite/prod/0.7/01__remove_triggers.sql rename to store/migration/sqlite/0.7/01__remove_triggers.sql diff --git a/store/migration/sqlite/prod/0.8/00__migration_history.sql b/store/migration/sqlite/0.8/00__migration_history.sql similarity index 100% rename from store/migration/sqlite/prod/0.8/00__migration_history.sql rename to store/migration/sqlite/0.8/00__migration_history.sql diff --git a/store/migration/sqlite/prod/0.8/01__user_username.sql b/store/migration/sqlite/0.8/01__user_username.sql similarity index 100% rename from store/migration/sqlite/prod/0.8/01__user_username.sql rename to store/migration/sqlite/0.8/01__user_username.sql diff --git a/store/migration/sqlite/prod/0.9/00__tag.sql b/store/migration/sqlite/0.9/00__tag.sql similarity index 100% rename from store/migration/sqlite/prod/0.9/00__tag.sql rename to store/migration/sqlite/0.9/00__tag.sql diff --git a/store/migration/sqlite/prod/LATEST.sql b/store/migration/sqlite/LATEST.sql similarity index 95% rename from store/migration/sqlite/prod/LATEST.sql rename to store/migration/sqlite/LATEST.sql index 8052de8c..0fe39cc4 100644 --- a/store/migration/sqlite/prod/LATEST.sql +++ b/store/migration/sqlite/LATEST.sql @@ -47,14 +47,11 @@ CREATE TABLE memo ( row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED')) DEFAULT 'NORMAL', content TEXT NOT NULL DEFAULT '', visibility TEXT NOT NULL CHECK (visibility IN ('PUBLIC', 'PROTECTED', 'PRIVATE')) DEFAULT 'PRIVATE', - tags TEXT NOT NULL DEFAULT '[]', + pinned INTEGER NOT NULL CHECK (pinned IN (0, 1)) DEFAULT 0, payload TEXT NOT NULL DEFAULT '{}' ); CREATE INDEX idx_memo_creator_id ON memo (creator_id); -CREATE INDEX idx_memo_content ON memo (content); -CREATE INDEX idx_memo_visibility ON memo (visibility); -CREATE INDEX idx_memo_tags ON memo (tags); -- memo_organizer CREATE TABLE memo_organizer ( diff --git a/store/migration/sqlite/dev/LATEST.sql b/store/migration/sqlite/dev/LATEST.sql deleted file mode 100644 index 42932b88..00000000 --- a/store/migration/sqlite/dev/LATEST.sql +++ /dev/null @@ -1,135 +0,0 @@ --- migration_history -CREATE TABLE migration_history ( - version TEXT NOT NULL PRIMARY KEY, - created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')) -); - --- system_setting -CREATE TABLE system_setting ( - name TEXT NOT NULL, - value TEXT NOT NULL, - description TEXT NOT NULL DEFAULT '', - UNIQUE(name) -); - --- user -CREATE TABLE user ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), - updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), - row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED')) DEFAULT 'NORMAL', - username TEXT NOT NULL UNIQUE, - role TEXT NOT NULL CHECK (role IN ('HOST', 'ADMIN', 'USER')) DEFAULT 'USER', - email TEXT NOT NULL DEFAULT '', - nickname TEXT NOT NULL DEFAULT '', - password_hash TEXT NOT NULL, - avatar_url TEXT NOT NULL DEFAULT '', - description TEXT NOT NULL DEFAULT '' -); - -CREATE INDEX idx_user_username ON user (username); - --- user_setting -CREATE TABLE user_setting ( - user_id INTEGER NOT NULL, - key TEXT NOT NULL, - value TEXT NOT NULL, - UNIQUE(user_id, key) -); - --- memo -CREATE TABLE memo ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - uid TEXT NOT NULL UNIQUE, - creator_id INTEGER NOT NULL, - created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), - updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), - row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED')) DEFAULT 'NORMAL', - content TEXT NOT NULL DEFAULT '', - visibility TEXT NOT NULL CHECK (visibility IN ('PUBLIC', 'PROTECTED', 'PRIVATE')) DEFAULT 'PRIVATE', - pinned INTEGER NOT NULL CHECK (pinned IN (0, 1)) DEFAULT 0, - payload TEXT NOT NULL DEFAULT '{}' -); - -CREATE INDEX idx_memo_creator_id ON memo (creator_id); - --- memo_relation -CREATE TABLE memo_relation ( - memo_id INTEGER NOT NULL, - related_memo_id INTEGER NOT NULL, - type TEXT NOT NULL, - UNIQUE(memo_id, related_memo_id, type) -); - --- resource -CREATE TABLE resource ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - uid TEXT NOT NULL UNIQUE, - creator_id INTEGER NOT NULL, - created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), - updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), - filename TEXT NOT NULL DEFAULT '', - blob BLOB DEFAULT NULL, - type TEXT NOT NULL DEFAULT '', - size INTEGER NOT NULL DEFAULT 0, - memo_id INTEGER, - storage_type TEXT NOT NULL DEFAULT '', - reference TEXT NOT NULL DEFAULT '', - payload TEXT NOT NULL DEFAULT '{}' -); - -CREATE INDEX idx_resource_creator_id ON resource (creator_id); - -CREATE INDEX idx_resource_memo_id ON resource (memo_id); - --- activity -CREATE TABLE activity ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - creator_id INTEGER NOT NULL, - created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), - type TEXT NOT NULL DEFAULT '', - level TEXT NOT NULL CHECK (level IN ('INFO', 'WARN', 'ERROR')) DEFAULT 'INFO', - payload TEXT NOT NULL DEFAULT '{}' -); - --- idp -CREATE TABLE idp ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT NOT NULL, - type TEXT NOT NULL, - identifier_filter TEXT NOT NULL DEFAULT '', - config TEXT NOT NULL DEFAULT '{}' -); - --- inbox -CREATE TABLE inbox ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), - sender_id INTEGER NOT NULL, - receiver_id INTEGER NOT NULL, - status TEXT NOT NULL, - message TEXT NOT NULL DEFAULT '{}' -); - --- webhook -CREATE TABLE webhook ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), - updated_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), - row_status TEXT NOT NULL CHECK (row_status IN ('NORMAL', 'ARCHIVED')) DEFAULT 'NORMAL', - creator_id INTEGER NOT NULL, - name TEXT NOT NULL, - url TEXT NOT NULL -); - -CREATE INDEX idx_webhook_creator_id ON webhook (creator_id); - --- reaction -CREATE TABLE reaction ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')), - creator_id INTEGER NOT NULL, - content_id TEXT NOT NULL, - reaction_type TEXT NOT NULL, - UNIQUE(creator_id, content_id, reaction_type) -); diff --git a/store/migration/sqlite/prod/0.24/00__memo_tags.sql b/store/migration/sqlite/prod/0.24/00__memo_tags.sql deleted file mode 100644 index ed5bbc02..00000000 --- a/store/migration/sqlite/prod/0.24/00__memo_tags.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Drop deprecated tags column. -ALTER TABLE memo DROP COLUMN tags; - -DROP INDEX IF EXISTS idx_memo_tags; diff --git a/store/migrator.go b/store/migrator.go index 7ac5445e..2469e55c 100644 --- a/store/migrator.go +++ b/store/migrator.go @@ -166,11 +166,7 @@ func (s *Store) preMigrate(ctx context.Context) error { } func (s *Store) getMigrationBasePath() string { - mode := "dev" - if s.Profile.Mode == "prod" { - mode = "prod" - } - return fmt.Sprintf("migration/%s/%s/", s.Profile.Driver, mode) + return fmt.Sprintf("migration/%s/", s.Profile.Driver) } func (s *Store) getSeedBasePath() string {