Skip to content

armgit / memos

Public Imported from GitHub
0

Memos is an open-source, self-hosted note-taking app that brings your everyday thoughts together in a personal timeline. Your data stays yours, and you choose what to keep private or share.

chore: update `memo` visibility field (#132)

boojack3d33b5d564ba
diff --git a/common/version.go b/common/version.go
index b0f7daa38..009b13c0e 100644
--- a/common/version.go
+++ b/common/version.go
@@ -10,7 +10,7 @@ import (
var Version = "0.2.2"
// DevVersion is the service current development version.
-var DevVersion = "0.2.2"
+var DevVersion = "0.3.0"
func GetCurrentVersion(mode string) string {
if mode == "dev" {
diff --git a/store/db/migration/0.2/00__user_role.sql b/store/db/migration/0.2/00__user_role.sql
index 942dc6c02..8620cde71 100644
--- a/store/db/migration/0.2/00__user_role.sql
+++ b/store/db/migration/0.2/00__user_role.sql
@@ -4,8 +4,7 @@ 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,
diff --git a/store/db/migration/0.3/00__memo_visibility_protected.sql b/store/db/migration/0.3/00__memo_visibility_protected.sql
new file mode 100644
index 000000000..24c62e3a0
--- /dev/null
+++ b/store/db/migration/0.3/00__memo_visibility_protected.sql
@@ -0,0 +1,37 @@
+-- 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;
+
+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',
+ 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,
+ visibility
+FROM
+ _memo_old;
+
+DROP TABLE IF EXISTS _memo_old;
+
+PRAGMA foreign_keys = on;
diff --git a/store/db/migration/LATEST__SCHEMA.sql b/store/db/migration/LATEST__SCHEMA.sql
index 6591bdecc..ca0bb1480 100644
--- a/store/db/migration/LATEST__SCHEMA.sql
+++ b/store/db/migration/LATEST__SCHEMA.sql
@@ -44,7 +44,7 @@ CREATE TABLE memo (
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', 'PRIVATE')) DEFAULT 'PRIVATE',
+ visibility TEXT NOT NULL CHECK (visibility IN ('PUBLIC', 'PROTECTED', 'PRIVATE')) DEFAULT 'PRIVATE',
FOREIGN KEY(creator_id) REFERENCES user(id) ON DELETE CASCADE
);