mirror of
https://github.com/usememos/memos.git
synced 2025-04-03 04:11:20 +02:00
parent
82f61f2a0e
commit
848ecd99ee
@ -1,10 +1,10 @@
|
||||
-- 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,
|
||||
@ -18,10 +18,17 @@ CREATE TABLE user (
|
||||
open_id TEXT NOT NULL UNIQUE
|
||||
);
|
||||
|
||||
INSERT INTO user (
|
||||
id, created_ts, updated_ts, row_status,
|
||||
email, name, password_hash, open_id
|
||||
)
|
||||
INSERT INTO
|
||||
user (
|
||||
id,
|
||||
created_ts,
|
||||
updated_ts,
|
||||
row_status,
|
||||
email,
|
||||
name,
|
||||
password_hash,
|
||||
open_id
|
||||
)
|
||||
SELECT
|
||||
id,
|
||||
created_ts,
|
||||
|
@ -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';
|
@ -1,10 +1,10 @@
|
||||
-- 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,
|
||||
@ -17,10 +17,16 @@ CREATE TABLE memo (
|
||||
FOREIGN KEY(creator_id) REFERENCES user(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
INSERT INTO memo (
|
||||
id, creator_id, created_ts, updated_ts,
|
||||
row_status, content, visibility
|
||||
)
|
||||
INSERT INTO
|
||||
memo (
|
||||
id,
|
||||
creator_id,
|
||||
created_ts,
|
||||
updated_ts,
|
||||
row_status,
|
||||
content,
|
||||
visibility
|
||||
)
|
||||
SELECT
|
||||
id,
|
||||
creator_id,
|
||||
|
@ -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;
|
@ -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 '';
|
@ -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;
|
@ -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,11 +118,18 @@ 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,
|
||||
@ -115,7 +147,8 @@ 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;
|
@ -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`;
|
@ -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,11 +20,19 @@ 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,
|
||||
|
@ -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;
|
@ -15,7 +15,7 @@ VALUES
|
||||
'HOST',
|
||||
'demo@usememos.com',
|
||||
'Demo Hero',
|
||||
'demo_open_id',
|
||||
hex(randomblob(16)),
|
||||
-- raw password: secret
|
||||
'$2a$14$ajq8Q7fbtFRQvXpdCq7Jcuy.Rx1h/L4J60Otx.gyNLbAYctGMJ9tK'
|
||||
);
|
||||
@ -37,7 +37,7 @@ VALUES
|
||||
'USER',
|
||||
'jack@usememos.com',
|
||||
'Jack',
|
||||
'jack_open_id',
|
||||
hex(randomblob(16)),
|
||||
-- raw password: secret
|
||||
'$2a$14$ajq8Q7fbtFRQvXpdCq7Jcuy.Rx1h/L4J60Otx.gyNLbAYctGMJ9tK'
|
||||
);
|
||||
@ -61,7 +61,7 @@ VALUES
|
||||
'USER',
|
||||
'bob@usememos.com',
|
||||
'Bob',
|
||||
'bob_open_id',
|
||||
hex(randomblob(16)),
|
||||
-- raw password: secret
|
||||
'$2a$14$ajq8Q7fbtFRQvXpdCq7Jcuy.Rx1h/L4J60Otx.gyNLbAYctGMJ9tK'
|
||||
);
|
@ -1,9 +1,5 @@
|
||||
INSERT INTO
|
||||
memo (
|
||||
`id`,
|
||||
`content`,
|
||||
`creator_id`
|
||||
)
|
||||
memo (`id`, `content`, `creator_id`)
|
||||
VALUES
|
||||
(
|
||||
1001,
|
||||
|
@ -1,25 +1,9 @@
|
||||
INSERT INTO
|
||||
memo_organizer (
|
||||
`memo_id`,
|
||||
`user_id`,
|
||||
`pinned`
|
||||
)
|
||||
memo_organizer (`memo_id`, `user_id`, `pinned`)
|
||||
VALUES
|
||||
(
|
||||
1001,
|
||||
101,
|
||||
1
|
||||
);
|
||||
(1001, 101, 1);
|
||||
|
||||
INSERT INTO
|
||||
memo_organizer (
|
||||
`memo_id`,
|
||||
`user_id`,
|
||||
`pinned`
|
||||
)
|
||||
memo_organizer (`memo_id`, `user_id`, `pinned`)
|
||||
VALUES
|
||||
(
|
||||
1003,
|
||||
101,
|
||||
1
|
||||
);
|
||||
(1003, 101, 1);
|
@ -1,12 +1,4 @@
|
||||
INSERT INTO
|
||||
system_setting (
|
||||
`name`,
|
||||
`value`,
|
||||
`description`
|
||||
)
|
||||
system_setting (`name`, `value`, `description`)
|
||||
VALUES
|
||||
(
|
||||
'allowSignUp',
|
||||
'true',
|
||||
''
|
||||
);
|
||||
('allowSignUp', 'true', '');
|
@ -1,32 +1,14 @@
|
||||
INSERT INTO
|
||||
tag (
|
||||
`name`,
|
||||
`creator_id`
|
||||
)
|
||||
tag (`name`, `creator_id`)
|
||||
VALUES
|
||||
(
|
||||
'Hello',
|
||||
101
|
||||
);
|
||||
('Hello', 101);
|
||||
|
||||
INSERT INTO
|
||||
tag (
|
||||
`name`,
|
||||
`creator_id`
|
||||
)
|
||||
tag (`name`, `creator_id`)
|
||||
VALUES
|
||||
(
|
||||
'TODO',
|
||||
101
|
||||
);
|
||||
('TODO', 101);
|
||||
|
||||
INSERT INTO
|
||||
tag (
|
||||
`name`,
|
||||
`creator_id`
|
||||
)
|
||||
tag (`name`, `creator_id`)
|
||||
VALUES
|
||||
(
|
||||
'TODO',
|
||||
102
|
||||
);
|
||||
('TODO', 102);
|
Loading…
x
Reference in New Issue
Block a user