From 848ecd99eeb6d5ec37bf13c58e1c9b45dc182777 Mon Sep 17 00:00:00 2001 From: boojack Date: Sun, 22 Jan 2023 21:16:03 +0800 Subject: [PATCH] chore: format SQL (#987) chore: format sql --- store/db/migration/dev/LATEST__SCHEMA.sql | 2 +- store/db/migration/prod/0.10/00__activity.sql | 2 +- store/db/migration/prod/0.2/00__user_role.sql | 77 +++++++------ .../prod/0.2/01__memo_visibility.sql | 5 +- .../0.3/00__memo_visibility_protected.sql | 50 +++++---- .../migration/prod/0.4/00__user_setting.sql | 2 +- .../prod/0.5/00__regenerate_foreign_keys.sql | 68 +++++++++--- .../migration/prod/0.5/01__memo_resource.sql | 2 +- .../migration/prod/0.5/02__system_setting.sql | 2 +- .../prod/0.5/03__resource_extermal_link.sql | 5 +- .../prod/0.6/00__recreate_triggers.sql | 6 +- store/db/migration/prod/0.7/00__remove_fk.sql | 104 +++++++++++++----- .../prod/0.7/01__remove_triggers.sql | 5 +- .../prod/0.8/00__migration_history.sql | 2 +- .../migration/prod/0.8/01__user_username.sql | 45 +++++--- store/db/migration/prod/0.9/00__tag.sql | 2 +- store/db/migration/prod/LATEST__SCHEMA.sql | 2 +- store/db/seed/10000__reset.sql | 19 +++- store/db/seed/10001__user.sql | 40 +++---- store/db/seed/10002__memo.sql | 34 +++--- store/db/seed/10003__memo_organizer.sql | 28 +---- store/db/seed/10004__shortcut.sql | 8 +- store/db/seed/10005__system_setting.sql | 14 +-- store/db/seed/10006__tag.sql | 36 ++---- 24 files changed, 321 insertions(+), 239 deletions(-) diff --git a/store/db/migration/dev/LATEST__SCHEMA.sql b/store/db/migration/dev/LATEST__SCHEMA.sql index 7e94c601..fa10f070 100644 --- a/store/db/migration/dev/LATEST__SCHEMA.sql +++ b/store/db/migration/dev/LATEST__SCHEMA.sql @@ -102,4 +102,4 @@ CREATE TABLE activity ( type TEXT NOT NULL DEFAULT '', level TEXT NOT NULL CHECK (level IN ('INFO', 'WARN', 'ERROR')) DEFAULT 'INFO', payload TEXT NOT NULL DEFAULT '{}' -); +); \ No newline at end of file diff --git a/store/db/migration/prod/0.10/00__activity.sql b/store/db/migration/prod/0.10/00__activity.sql index 0d4b05e7..459468d6 100644 --- a/store/db/migration/prod/0.10/00__activity.sql +++ b/store/db/migration/prod/0.10/00__activity.sql @@ -6,4 +6,4 @@ CREATE TABLE activity ( type TEXT NOT NULL DEFAULT '', level TEXT NOT NULL CHECK (level IN ('INFO', 'WARN', 'ERROR')) DEFAULT 'INFO', payload TEXT NOT NULL DEFAULT '{}' -); +); \ No newline at end of file diff --git a/store/db/migration/prod/0.2/00__user_role.sql b/store/db/migration/prod/0.2/00__user_role.sql index 8620cde7..e6a312e9 100644 --- a/store/db/migration/prod/0.2/00__user_role.sql +++ b/store/db/migration/prod/0.2/00__user_role.sql @@ -1,53 +1,60 @@ -- change user role field from "OWNER"/"USER" to "HOST"/"USER". - PRAGMA foreign_keys = off; DROP TABLE IF EXISTS _user_old; -ALTER TABLE user RENAME TO _user_old; +ALTER TABLE + user RENAME TO _user_old; 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', - email TEXT NOT NULL UNIQUE, - role TEXT NOT NULL CHECK (role IN ('HOST', 'USER')) DEFAULT 'USER', - name TEXT NOT NULL, - password_hash TEXT NOT NULL, + 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', + email TEXT NOT NULL UNIQUE, + role TEXT NOT NULL CHECK (role IN ('HOST', 'USER')) DEFAULT 'USER', + name TEXT NOT NULL, + password_hash TEXT NOT NULL, open_id TEXT NOT NULL UNIQUE ); -INSERT INTO user ( - id, created_ts, updated_ts, row_status, - email, name, password_hash, open_id -) -SELECT - id, - created_ts, - updated_ts, - row_status, - email, - name, - password_hash, - open_id -FROM +INSERT INTO + user ( + id, + created_ts, + updated_ts, + row_status, + email, + name, + password_hash, + open_id + ) +SELECT + id, + created_ts, + updated_ts, + row_status, + email, + name, + password_hash, + open_id +FROM _user_old; -UPDATE - user -SET - role = 'HOST' -WHERE +UPDATE + user +SET + role = 'HOST' +WHERE id IN ( - SELECT - id - FROM - _user_old - WHERE + SELECT + id + FROM + _user_old + WHERE role = 'OWNER' ); DROP TABLE IF EXISTS _user_old; -PRAGMA foreign_keys = on; +PRAGMA foreign_keys = on; \ No newline at end of file diff --git a/store/db/migration/prod/0.2/01__memo_visibility.sql b/store/db/migration/prod/0.2/01__memo_visibility.sql index 1ae37829..84a00dae 100644 --- a/store/db/migration/prod/0.2/01__memo_visibility.sql +++ b/store/db/migration/prod/0.2/01__memo_visibility.sql @@ -1 +1,4 @@ -ALTER TABLE memo ADD COLUMN visibility TEXT NOT NULL CHECK (visibility IN ('PUBLIC', 'PRIVATE')) DEFAULT 'PRIVATE'; +ALTER TABLE + memo +ADD + COLUMN visibility TEXT NOT NULL CHECK (visibility IN ('PUBLIC', 'PRIVATE')) DEFAULT 'PRIVATE'; \ No newline at end of file diff --git a/store/db/migration/prod/0.3/00__memo_visibility_protected.sql b/store/db/migration/prod/0.3/00__memo_visibility_protected.sql index 24c62e3a..b960f4a6 100644 --- a/store/db/migration/prod/0.3/00__memo_visibility_protected.sql +++ b/store/db/migration/prod/0.3/00__memo_visibility_protected.sql @@ -1,37 +1,43 @@ -- change memo visibility field from "PRIVATE"/"PUBLIC" to "PRIVATE"/"PROTECTED"/"PUBLIC". - PRAGMA foreign_keys = off; DROP TABLE IF EXISTS _memo_old; -ALTER TABLE memo RENAME TO _memo_old; +ALTER TABLE + memo RENAME TO _memo_old; CREATE TABLE memo ( - id INTEGER PRIMARY KEY AUTOINCREMENT, - 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', + id INTEGER PRIMARY KEY AUTOINCREMENT, + 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', FOREIGN KEY(creator_id) REFERENCES user(id) ON DELETE CASCADE ); -INSERT INTO memo ( - id, creator_id, created_ts, updated_ts, - row_status, content, visibility -) -SELECT - id, - creator_id, - created_ts, - updated_ts, - row_status, - content, +INSERT INTO + memo ( + id, + creator_id, + created_ts, + updated_ts, + row_status, + content, + visibility + ) +SELECT + id, + creator_id, + created_ts, + updated_ts, + row_status, + content, visibility -FROM +FROM _memo_old; DROP TABLE IF EXISTS _memo_old; -PRAGMA foreign_keys = on; +PRAGMA foreign_keys = on; \ No newline at end of file diff --git a/store/db/migration/prod/0.4/00__user_setting.sql b/store/db/migration/prod/0.4/00__user_setting.sql index be65387f..1f9e54c2 100644 --- a/store/db/migration/prod/0.4/00__user_setting.sql +++ b/store/db/migration/prod/0.4/00__user_setting.sql @@ -6,4 +6,4 @@ CREATE TABLE user_setting ( FOREIGN KEY(user_id) REFERENCES user(id) ON DELETE CASCADE ); -CREATE UNIQUE INDEX user_setting_key_user_id_index ON user_setting(key, user_id); +CREATE UNIQUE INDEX user_setting_key_user_id_index ON user_setting(key, user_id); \ No newline at end of file diff --git a/store/db/migration/prod/0.5/00__regenerate_foreign_keys.sql b/store/db/migration/prod/0.5/00__regenerate_foreign_keys.sql index 66f3bf04..00ed430a 100644 --- a/store/db/migration/prod/0.5/00__regenerate_foreign_keys.sql +++ b/store/db/migration/prod/0.5/00__regenerate_foreign_keys.sql @@ -1,8 +1,9 @@ -PRAGMA foreign_keys=off; +PRAGMA foreign_keys = off; DROP TABLE IF EXISTS _user_old; -ALTER TABLE user RENAME TO _user_old; +ALTER TABLE + user RENAME TO _user_old; -- user CREATE TABLE user ( @@ -17,7 +18,12 @@ CREATE TABLE user ( open_id TEXT NOT NULL UNIQUE ); -INSERT INTO user SELECT * FROM _user_old; +INSERT INTO + user +SELECT + * +FROM + _user_old; DROP TABLE IF EXISTS _user_old; @@ -33,11 +39,13 @@ SET updated_ts = (strftime('%s', 'now')) WHERE rowid = old.rowid; + END; DROP TABLE IF EXISTS _memo_old; -ALTER TABLE memo RENAME TO _memo_old; +ALTER TABLE + memo RENAME TO _memo_old; -- memo CREATE TABLE memo ( @@ -51,7 +59,12 @@ CREATE TABLE memo ( FOREIGN KEY(creator_id) REFERENCES user(id) ON DELETE CASCADE ); -INSERT INTO memo SELECT * FROM _memo_old; +INSERT INTO + memo +SELECT + * +FROM + _memo_old; DROP TABLE IF EXISTS _memo_old; @@ -67,11 +80,13 @@ SET updated_ts = (strftime('%s', 'now')) WHERE rowid = old.rowid; + END; DROP TABLE IF EXISTS _memo_organizer_old; -ALTER TABLE memo_organizer RENAME TO _memo_organizer_old; +ALTER TABLE + memo_organizer RENAME TO _memo_organizer_old; -- memo_organizer CREATE TABLE memo_organizer ( @@ -84,13 +99,19 @@ CREATE TABLE memo_organizer ( UNIQUE(memo_id, user_id) ); -INSERT INTO memo_organizer SELECT * FROM _memo_organizer_old; +INSERT INTO + memo_organizer +SELECT + * +FROM + _memo_organizer_old; DROP TABLE IF EXISTS _memo_organizer_old; DROP TABLE IF EXISTS _shortcut_old; -ALTER TABLE shortcut RENAME TO _shortcut_old; +ALTER TABLE + shortcut RENAME TO _shortcut_old; -- shortcut CREATE TABLE shortcut ( @@ -104,7 +125,12 @@ CREATE TABLE shortcut ( FOREIGN KEY(creator_id) REFERENCES user(id) ON DELETE CASCADE ); -INSERT INTO shortcut SELECT * FROM _shortcut_old; +INSERT INTO + shortcut +SELECT + * +FROM + _shortcut_old; DROP TABLE IF EXISTS _shortcut_old; @@ -120,11 +146,13 @@ SET updated_ts = (strftime('%s', 'now')) WHERE rowid = old.rowid; + END; DROP TABLE IF EXISTS _resource_old; -ALTER TABLE resource RENAME TO _resource_old; +ALTER TABLE + resource RENAME TO _resource_old; -- resource CREATE TABLE resource ( @@ -139,7 +167,12 @@ CREATE TABLE resource ( FOREIGN KEY(creator_id) REFERENCES user(id) ON DELETE CASCADE ); -INSERT INTO resource SELECT * FROM _resource_old; +INSERT INTO + resource +SELECT + * +FROM + _resource_old; DROP TABLE IF EXISTS _resource_old; @@ -155,11 +188,13 @@ SET updated_ts = (strftime('%s', 'now')) WHERE rowid = old.rowid; + END; DROP TABLE IF EXISTS _user_setting_old; -ALTER TABLE user_setting RENAME TO _user_setting_old; +ALTER TABLE + user_setting RENAME TO _user_setting_old; -- user_setting CREATE TABLE user_setting ( @@ -170,8 +205,13 @@ CREATE TABLE user_setting ( UNIQUE(user_id, key) ); -INSERT INTO user_setting SELECT * FROM _user_setting_old; +INSERT INTO + user_setting +SELECT + * +FROM + _user_setting_old; DROP TABLE IF EXISTS _user_setting_old; -PRAGMA foreign_keys=on; +PRAGMA foreign_keys = on; \ No newline at end of file diff --git a/store/db/migration/prod/0.5/01__memo_resource.sql b/store/db/migration/prod/0.5/01__memo_resource.sql index 6a98fa00..0a798ae8 100644 --- a/store/db/migration/prod/0.5/01__memo_resource.sql +++ b/store/db/migration/prod/0.5/01__memo_resource.sql @@ -7,4 +7,4 @@ CREATE TABLE memo_resource ( FOREIGN KEY(memo_id) REFERENCES memo(id) ON DELETE CASCADE, FOREIGN KEY(resource_id) REFERENCES resource(id) ON DELETE CASCADE, UNIQUE(memo_id, resource_id) -); +); \ No newline at end of file diff --git a/store/db/migration/prod/0.5/02__system_setting.sql b/store/db/migration/prod/0.5/02__system_setting.sql index 4f154049..90879098 100644 --- a/store/db/migration/prod/0.5/02__system_setting.sql +++ b/store/db/migration/prod/0.5/02__system_setting.sql @@ -4,4 +4,4 @@ CREATE TABLE system_setting ( value TEXT NOT NULL, description TEXT NOT NULL DEFAULT '', UNIQUE(name) -); +); \ No newline at end of file diff --git a/store/db/migration/prod/0.5/03__resource_extermal_link.sql b/store/db/migration/prod/0.5/03__resource_extermal_link.sql index 64bbf530..b346bdac 100644 --- a/store/db/migration/prod/0.5/03__resource_extermal_link.sql +++ b/store/db/migration/prod/0.5/03__resource_extermal_link.sql @@ -1 +1,4 @@ -ALTER TABLE resource ADD COLUMN external_link TEXT NOT NULL DEFAULT ''; +ALTER TABLE + resource +ADD + COLUMN external_link TEXT NOT NULL DEFAULT ''; \ No newline at end of file diff --git a/store/db/migration/prod/0.6/00__recreate_triggers.sql b/store/db/migration/prod/0.6/00__recreate_triggers.sql index 06419dc2..4f1f1dcf 100644 --- a/store/db/migration/prod/0.6/00__recreate_triggers.sql +++ b/store/db/migration/prod/0.6/00__recreate_triggers.sql @@ -10,6 +10,7 @@ SET updated_ts = (strftime('%s', 'now')) WHERE rowid = old.rowid; + END; DROP TRIGGER IF EXISTS `trigger_update_memo_modification_time`; @@ -24,6 +25,7 @@ SET updated_ts = (strftime('%s', 'now')) WHERE rowid = old.rowid; + END; DROP TRIGGER IF EXISTS `trigger_update_shortcut_modification_time`; @@ -38,6 +40,7 @@ SET updated_ts = (strftime('%s', 'now')) WHERE rowid = old.rowid; + END; DROP TRIGGER IF EXISTS `trigger_update_resource_modification_time`; @@ -52,4 +55,5 @@ SET updated_ts = (strftime('%s', 'now')) WHERE rowid = old.rowid; -END; + +END; \ No newline at end of file diff --git a/store/db/migration/prod/0.7/00__remove_fk.sql b/store/db/migration/prod/0.7/00__remove_fk.sql index b4e301df..84d4112a 100644 --- a/store/db/migration/prod/0.7/00__remove_fk.sql +++ b/store/db/migration/prod/0.7/00__remove_fk.sql @@ -1,8 +1,9 @@ -PRAGMA foreign_keys=off; +PRAGMA foreign_keys = off; DROP TABLE IF EXISTS _user_old; -ALTER TABLE user RENAME TO _user_old; +ALTER TABLE + user RENAME TO _user_old; -- user CREATE TABLE user ( @@ -17,13 +18,19 @@ CREATE TABLE user ( open_id TEXT NOT NULL UNIQUE ); -INSERT INTO user SELECT * FROM _user_old; +INSERT INTO + user +SELECT + * +FROM + _user_old; DROP TABLE IF EXISTS _user_old; DROP TABLE IF EXISTS _memo_old; -ALTER TABLE memo RENAME TO _memo_old; +ALTER TABLE + memo RENAME TO _memo_old; -- memo CREATE TABLE memo ( @@ -36,13 +43,19 @@ CREATE TABLE memo ( visibility TEXT NOT NULL CHECK (visibility IN ('PUBLIC', 'PROTECTED', 'PRIVATE')) DEFAULT 'PRIVATE' ); -INSERT INTO memo SELECT * FROM _memo_old; +INSERT INTO + memo +SELECT + * +FROM + _memo_old; DROP TABLE IF EXISTS _memo_old; DROP TABLE IF EXISTS _memo_organizer_old; -ALTER TABLE memo_organizer RENAME TO _memo_organizer_old; +ALTER TABLE + memo_organizer RENAME TO _memo_organizer_old; -- memo_organizer CREATE TABLE memo_organizer ( @@ -53,13 +66,19 @@ CREATE TABLE memo_organizer ( UNIQUE(memo_id, user_id) ); -INSERT INTO memo_organizer SELECT * FROM _memo_organizer_old; +INSERT INTO + memo_organizer +SELECT + * +FROM + _memo_organizer_old; DROP TABLE IF EXISTS _memo_organizer_old; DROP TABLE IF EXISTS _shortcut_old; -ALTER TABLE shortcut RENAME TO _shortcut_old; +ALTER TABLE + shortcut RENAME TO _shortcut_old; -- shortcut CREATE TABLE shortcut ( @@ -72,13 +91,19 @@ CREATE TABLE shortcut ( payload TEXT NOT NULL DEFAULT '{}' ); -INSERT INTO shortcut SELECT * FROM _shortcut_old; +INSERT INTO + shortcut +SELECT + * +FROM + _shortcut_old; DROP TABLE IF EXISTS _shortcut_old; DROP TABLE IF EXISTS _resource_old; -ALTER TABLE resource RENAME TO _resource_old; +ALTER TABLE + resource RENAME TO _resource_old; -- resource CREATE TABLE resource ( @@ -93,29 +118,37 @@ CREATE TABLE resource ( size INTEGER NOT NULL DEFAULT 0 ); -INSERT INTO resource ( - id, creator_id, created_ts, updated_ts, - filename, blob, external_link, type, +INSERT INTO + resource ( + id, + creator_id, + created_ts, + updated_ts, + filename, + blob, + external_link, + type, + size + ) +SELECT + id, + creator_id, + created_ts, + updated_ts, + filename, + blob, + external_link, + type, size -) -SELECT - id, - creator_id, - created_ts, - updated_ts, - filename, - blob, - external_link, - type, - size -FROM +FROM _resource_old; DROP TABLE IF EXISTS _resource_old; DROP TABLE IF EXISTS _user_setting_old; -ALTER TABLE user_setting RENAME TO _user_setting_old; +ALTER TABLE + user_setting RENAME TO _user_setting_old; -- user_setting CREATE TABLE user_setting ( @@ -125,13 +158,19 @@ CREATE TABLE user_setting ( UNIQUE(user_id, key) ); -INSERT INTO user_setting SELECT * FROM _user_setting_old; +INSERT INTO + user_setting +SELECT + * +FROM + _user_setting_old; DROP TABLE IF EXISTS _user_setting_old; DROP TABLE IF EXISTS _memo_resource_old; -ALTER TABLE memo_resource RENAME TO _memo_resource_old; +ALTER TABLE + memo_resource RENAME TO _memo_resource_old; -- memo_resource CREATE TABLE memo_resource ( @@ -142,6 +181,11 @@ CREATE TABLE memo_resource ( UNIQUE(memo_id, resource_id) ); -INSERT INTO memo_resource SELECT * FROM _memo_resource_old; +INSERT INTO + memo_resource +SELECT + * +FROM + _memo_resource_old; -DROP TABLE IF EXISTS _memo_resource_old; +DROP TABLE IF EXISTS _memo_resource_old; \ No newline at end of file diff --git a/store/db/migration/prod/0.7/01__remove_triggers.sql b/store/db/migration/prod/0.7/01__remove_triggers.sql index b0dc7cde..7f04c82e 100644 --- a/store/db/migration/prod/0.7/01__remove_triggers.sql +++ b/store/db/migration/prod/0.7/01__remove_triggers.sql @@ -1,4 +1,7 @@ DROP TRIGGER IF EXISTS `trigger_update_user_modification_time`; + DROP TRIGGER IF EXISTS `trigger_update_memo_modification_time`; + DROP TRIGGER IF EXISTS `trigger_update_shortcut_modification_time`; -DROP TRIGGER IF EXISTS `trigger_update_resource_modification_time`; + +DROP TRIGGER IF EXISTS `trigger_update_resource_modification_time`; \ No newline at end of file diff --git a/store/db/migration/prod/0.8/00__migration_history.sql b/store/db/migration/prod/0.8/00__migration_history.sql index 77ff52e7..96123446 100644 --- a/store/db/migration/prod/0.8/00__migration_history.sql +++ b/store/db/migration/prod/0.8/00__migration_history.sql @@ -2,4 +2,4 @@ CREATE TABLE IF NOT EXISTS migration_history ( version TEXT NOT NULL PRIMARY KEY, created_ts BIGINT NOT NULL DEFAULT (strftime('%s', 'now')) -); +); \ No newline at end of file diff --git a/store/db/migration/prod/0.8/01__user_username.sql b/store/db/migration/prod/0.8/01__user_username.sql index e23f6387..273ffe6b 100644 --- a/store/db/migration/prod/0.8/01__user_username.sql +++ b/store/db/migration/prod/0.8/01__user_username.sql @@ -3,7 +3,8 @@ -- add role `ADMIN` DROP TABLE IF EXISTS _user_old; -ALTER TABLE user RENAME TO _user_old; +ALTER TABLE + user RENAME TO _user_old; -- user CREATE TABLE user ( @@ -19,23 +20,31 @@ CREATE TABLE user ( open_id TEXT NOT NULL UNIQUE ); -INSERT INTO user ( - id, created_ts, updated_ts, row_status, - username, role, email, nickname, password_hash, +INSERT INTO + user ( + id, + created_ts, + updated_ts, + row_status, + username, + role, + email, + nickname, + password_hash, + open_id + ) +SELECT + id, + created_ts, + updated_ts, + row_status, + email, + role, + email, + name, + password_hash, open_id -) -SELECT - id, - created_ts, - updated_ts, - row_status, - email, - role, - email, - name, - password_hash, - open_id -FROM +FROM _user_old; -DROP TABLE IF EXISTS _user_old; +DROP TABLE IF EXISTS _user_old; \ No newline at end of file diff --git a/store/db/migration/prod/0.9/00__tag.sql b/store/db/migration/prod/0.9/00__tag.sql index 1f6613f2..89802d46 100644 --- a/store/db/migration/prod/0.9/00__tag.sql +++ b/store/db/migration/prod/0.9/00__tag.sql @@ -3,4 +3,4 @@ CREATE TABLE tag ( name TEXT NOT NULL, creator_id INTEGER NOT NULL, UNIQUE(name, creator_id) -); +); \ No newline at end of file diff --git a/store/db/migration/prod/LATEST__SCHEMA.sql b/store/db/migration/prod/LATEST__SCHEMA.sql index 7e94c601..fa10f070 100644 --- a/store/db/migration/prod/LATEST__SCHEMA.sql +++ b/store/db/migration/prod/LATEST__SCHEMA.sql @@ -102,4 +102,4 @@ CREATE TABLE activity ( type TEXT NOT NULL DEFAULT '', level TEXT NOT NULL CHECK (level IN ('INFO', 'WARN', 'ERROR')) DEFAULT 'INFO', payload TEXT NOT NULL DEFAULT '{}' -); +); \ No newline at end of file diff --git a/store/db/seed/10000__reset.sql b/store/db/seed/10000__reset.sql index 4b47589f..0394790f 100644 --- a/store/db/seed/10000__reset.sql +++ b/store/db/seed/10000__reset.sql @@ -1,5 +1,14 @@ -DELETE FROM memo_organizer; -DELETE FROM resource; -DELETE FROM shortcut; -DELETE FROM memo; -DELETE FROM user; +DELETE FROM + memo_organizer; + +DELETE FROM + resource; + +DELETE FROM + shortcut; + +DELETE FROM + memo; + +DELETE FROM + user; \ No newline at end of file diff --git a/store/db/seed/10001__user.sql b/store/db/seed/10001__user.sql index 5dd6f6c3..0cbdc51e 100644 --- a/store/db/seed/10001__user.sql +++ b/store/db/seed/10001__user.sql @@ -1,67 +1,67 @@ -INSERT INTO +INSERT INTO user ( - `id`, - `username`, + `id`, + `username`, `role`, `email`, - `nickname`, + `nickname`, `open_id`, `password_hash` ) VALUES ( - 101, + 101, 'demohero', 'HOST', 'demo@usememos.com', 'Demo Hero', - 'demo_open_id', + hex(randomblob(16)), -- raw password: secret '$2a$14$ajq8Q7fbtFRQvXpdCq7Jcuy.Rx1h/L4J60Otx.gyNLbAYctGMJ9tK' ); -INSERT INTO +INSERT INTO user ( - `id`, - `username`, + `id`, + `username`, `role`, `email`, - `nickname`, + `nickname`, `open_id`, `password_hash` ) VALUES ( - 102, + 102, 'jack', 'USER', 'jack@usememos.com', 'Jack', - 'jack_open_id', + hex(randomblob(16)), -- raw password: secret '$2a$14$ajq8Q7fbtFRQvXpdCq7Jcuy.Rx1h/L4J60Otx.gyNLbAYctGMJ9tK' ); -INSERT INTO +INSERT INTO user ( - `id`, - `row_status`, - `username`, + `id`, + `row_status`, + `username`, `role`, `email`, - `nickname`, + `nickname`, `open_id`, `password_hash` ) VALUES ( - 103, - 'ARCHIVED', + 103, + 'ARCHIVED', 'bob', 'USER', 'bob@usememos.com', 'Bob', - 'bob_open_id', + hex(randomblob(16)), -- raw password: secret '$2a$14$ajq8Q7fbtFRQvXpdCq7Jcuy.Rx1h/L4J60Otx.gyNLbAYctGMJ9tK' ); \ No newline at end of file diff --git a/store/db/seed/10002__memo.sql b/store/db/seed/10002__memo.sql index 50069fc7..0f11a1e5 100644 --- a/store/db/seed/10002__memo.sql +++ b/store/db/seed/10002__memo.sql @@ -1,20 +1,16 @@ -INSERT INTO - memo ( - `id`, - `content`, - `creator_id` - ) +INSERT INTO + memo (`id`, `content`, `creator_id`) VALUES ( 1001, - "#Hello πŸ‘‹ Welcome to memos.", + "#Hello πŸ‘‹ Welcome to memos.", 101 ); -INSERT INTO +INSERT INTO memo ( `id`, - `content`, + `content`, `creator_id`, `visibility` ) @@ -25,15 +21,15 @@ VALUES - [x] Take more photos about **πŸŒ„ sunset**; - [x] Clean the room; - [ ] Read *πŸ“– The Little Prince*; -(πŸ‘† click to toggle status)', +(πŸ‘† click to toggle status)', 101, 'PROTECTED' ); -INSERT INTO +INSERT INTO memo ( `id`, - `content`, + `content`, `creator_id`, `visibility` ) @@ -47,10 +43,10 @@ VALUES 'PUBLIC' ); -INSERT INTO +INSERT INTO memo ( `id`, - `content`, + `content`, `creator_id`, `visibility` ) @@ -62,22 +58,22 @@ VALUES - [ ] Clean the classroom; - [ ] Watch *πŸ‘¦ The Boys*; (πŸ‘† click to toggle status) -', +', 102, 'PROTECTED' ); -INSERT INTO +INSERT INTO memo ( `id`, - `content`, + `content`, `creator_id`, `visibility` ) VALUES ( 1005, - 'δΈ‰δΊΊθ‘ŒοΌŒεΏ…ζœ‰ζˆ‘εΈˆη„‰οΌπŸ‘¨β€πŸ«', + 'δΈ‰δΊΊθ‘ŒοΌŒεΏ…ζœ‰ζˆ‘εΈˆη„‰οΌπŸ‘¨β€πŸ«', 102, 'PUBLIC' - ); + ); \ No newline at end of file diff --git a/store/db/seed/10003__memo_organizer.sql b/store/db/seed/10003__memo_organizer.sql index cee1db13..324ea790 100644 --- a/store/db/seed/10003__memo_organizer.sql +++ b/store/db/seed/10003__memo_organizer.sql @@ -1,25 +1,9 @@ -INSERT INTO - memo_organizer ( - `memo_id`, - `user_id`, - `pinned` - ) +INSERT INTO + memo_organizer (`memo_id`, `user_id`, `pinned`) VALUES - ( - 1001, - 101, - 1 - ); + (1001, 101, 1); -INSERT INTO - memo_organizer ( - `memo_id`, - `user_id`, - `pinned` - ) +INSERT INTO + memo_organizer (`memo_id`, `user_id`, `pinned`) VALUES - ( - 1003, - 101, - 1 - ); + (1003, 101, 1); \ No newline at end of file diff --git a/store/db/seed/10004__shortcut.sql b/store/db/seed/10004__shortcut.sql index 799e408d..aac766ad 100644 --- a/store/db/seed/10004__shortcut.sql +++ b/store/db/seed/10004__shortcut.sql @@ -1,12 +1,12 @@ -INSERT INTO +INSERT INTO shortcut ( - `title`, + `title`, `creator_id`, `payload` ) VALUES ( - 'inbox', + 'inbox', 101, '[{"type":"TYPE","value":{"operator":"IS","value":"NOT_TAGGED"},"relation":"AND"}]' - ); + ); \ No newline at end of file diff --git a/store/db/seed/10005__system_setting.sql b/store/db/seed/10005__system_setting.sql index 9903a7ea..143c1dbb 100644 --- a/store/db/seed/10005__system_setting.sql +++ b/store/db/seed/10005__system_setting.sql @@ -1,12 +1,4 @@ -INSERT INTO - system_setting ( - `name`, - `value`, - `description` - ) +INSERT INTO + system_setting (`name`, `value`, `description`) VALUES - ( - 'allowSignUp', - 'true', - '' - ); + ('allowSignUp', 'true', ''); \ No newline at end of file diff --git a/store/db/seed/10006__tag.sql b/store/db/seed/10006__tag.sql index 5db2cfb6..2db7ce55 100644 --- a/store/db/seed/10006__tag.sql +++ b/store/db/seed/10006__tag.sql @@ -1,32 +1,14 @@ -INSERT INTO - tag ( - `name`, - `creator_id` - ) +INSERT INTO + tag (`name`, `creator_id`) VALUES - ( - 'Hello', - 101 - ); + ('Hello', 101); -INSERT INTO - tag ( - `name`, - `creator_id` - ) +INSERT INTO + tag (`name`, `creator_id`) VALUES - ( - 'TODO', - 101 - ); + ('TODO', 101); -INSERT INTO - tag ( - `name`, - `creator_id` - ) +INSERT INTO + tag (`name`, `creator_id`) VALUES - ( - 'TODO', - 102 - ); + ('TODO', 102); \ No newline at end of file