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.

revert: revert system_setting to instance_setting rename changes

Johnnycc9a214be8b2
diff --git a/store/db/mysql/instance_setting.go b/store/db/mysql/instance_setting.go
index 0febb4b87..28c8fe529 100644
--- a/store/db/mysql/instance_setting.go
+++ b/store/db/mysql/instance_setting.go
@@ -8,7 +8,7 @@ import (
)
func (d *DB) UpsertInstanceSetting(ctx context.Context, upsert *store.InstanceSetting) (*store.InstanceSetting, error) {
- stmt := "INSERT INTO `instance_setting` (`name`, `value`, `description`) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = ?, `description` = ?"
+ stmt := "INSERT INTO `system_setting` (`name`, `value`, `description`) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE `value` = ?, `description` = ?"
_, err := d.db.ExecContext(
ctx,
stmt,
@@ -31,7 +31,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS
where, args = append(where, "`name` = ?"), append(args, find.Name)
}
- query := "SELECT `name`, `value`, `description` FROM `instance_setting` WHERE " + strings.Join(where, " AND ")
+ query := "SELECT `name`, `value`, `description` FROM `system_setting` WHERE " + strings.Join(where, " AND ")
rows, err := d.db.QueryContext(ctx, query, args...)
if err != nil {
return nil, err
@@ -59,7 +59,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS
}
func (d *DB) DeleteInstanceSetting(ctx context.Context, delete *store.DeleteInstanceSetting) error {
- stmt := "DELETE FROM `instance_setting` WHERE `name` = ?"
+ stmt := "DELETE FROM `system_setting` WHERE `name` = ?"
_, err := d.db.ExecContext(ctx, stmt, delete.Name)
return err
}
diff --git a/store/db/postgres/instance_setting.go b/store/db/postgres/instance_setting.go
index 5a6621291..a2ec78c3e 100644
--- a/store/db/postgres/instance_setting.go
+++ b/store/db/postgres/instance_setting.go
@@ -9,7 +9,7 @@ import (
func (d *DB) UpsertInstanceSetting(ctx context.Context, upsert *store.InstanceSetting) (*store.InstanceSetting, error) {
stmt := `
- INSERT INTO instance_setting (
+ INSERT INTO system_setting (
name, value, description
)
VALUES ($1, $2, $3)
@@ -36,7 +36,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS
name,
value,
description
- FROM instance_setting
+ FROM system_setting
WHERE ` + strings.Join(where, " AND ")
rows, err := d.db.QueryContext(ctx, query, args...)
@@ -66,7 +66,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS
}
func (d *DB) DeleteInstanceSetting(ctx context.Context, delete *store.DeleteInstanceSetting) error {
- stmt := `DELETE FROM instance_setting WHERE name = $1`
+ stmt := `DELETE FROM system_setting WHERE name = $1`
_, err := d.db.ExecContext(ctx, stmt, delete.Name)
return err
}
diff --git a/store/db/sqlite/instance_setting.go b/store/db/sqlite/instance_setting.go
index d91dd35b9..658501fc8 100644
--- a/store/db/sqlite/instance_setting.go
+++ b/store/db/sqlite/instance_setting.go
@@ -9,7 +9,7 @@ import (
func (d *DB) UpsertInstanceSetting(ctx context.Context, upsert *store.InstanceSetting) (*store.InstanceSetting, error) {
stmt := `
- INSERT INTO instance_setting (
+ INSERT INTO system_setting (
name, value, description
)
VALUES (?, ?, ?)
@@ -36,7 +36,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS
name,
value,
description
- FROM instance_setting
+ FROM system_setting
WHERE ` + strings.Join(where, " AND ")
rows, err := d.db.QueryContext(ctx, query, args...)
@@ -66,7 +66,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS
}
func (d *DB) DeleteInstanceSetting(ctx context.Context, delete *store.DeleteInstanceSetting) error {
- stmt := "DELETE FROM instance_setting WHERE name = ?"
+ stmt := "DELETE FROM system_setting WHERE name = ?"
_, err := d.db.ExecContext(ctx, stmt, delete.Name)
return err
}
diff --git a/store/migration/mysql/0.26/01__rename_system_setting_to_instance_setting.sql b/store/migration/mysql/0.26/01__rename_system_setting_to_instance_setting.sql
deleted file mode 100644
index cb8481a93..000000000
--- a/store/migration/mysql/0.26/01__rename_system_setting_to_instance_setting.sql
+++ /dev/null
@@ -1 +0,0 @@
-RENAME TABLE system_setting TO instance_setting;
diff --git a/store/migration/mysql/LATEST.sql b/store/migration/mysql/LATEST.sql
index 8613d2fac..adc86a9eb 100644
--- a/store/migration/mysql/LATEST.sql
+++ b/store/migration/mysql/LATEST.sql
@@ -1,5 +1,5 @@
--- instance_setting
-CREATE TABLE `instance_setting` (
+-- system_setting
+CREATE TABLE `system_setting` (
`name` VARCHAR(256) NOT NULL PRIMARY KEY,
`value` LONGTEXT NOT NULL,
`description` TEXT NOT NULL
@@ -58,8 +58,8 @@ CREATE TABLE `memo_relation` (
UNIQUE(`memo_id`,`related_memo_id`,`type`)
);
--- attachment
-CREATE TABLE `attachment` (
+-- resource
+CREATE TABLE `resource` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`uid` VARCHAR(256) NOT NULL UNIQUE,
`creator_id` INT NOT NULL,
diff --git a/store/migration/postgres/0.26/01__rename_system_setting_to_instance_setting.sql b/store/migration/postgres/0.26/01__rename_system_setting_to_instance_setting.sql
deleted file mode 100644
index 057edb702..000000000
--- a/store/migration/postgres/0.26/01__rename_system_setting_to_instance_setting.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE system_setting RENAME TO instance_setting;
diff --git a/store/migration/postgres/LATEST.sql b/store/migration/postgres/LATEST.sql
index f227777a5..b5b70a9ec 100644
--- a/store/migration/postgres/LATEST.sql
+++ b/store/migration/postgres/LATEST.sql
@@ -1,5 +1,5 @@
--- instance_setting
-CREATE TABLE instance_setting (
+-- system_setting
+CREATE TABLE system_setting (
name TEXT NOT NULL PRIMARY KEY,
value TEXT NOT NULL,
description TEXT NOT NULL
@@ -58,8 +58,8 @@ CREATE TABLE memo_relation (
UNIQUE(memo_id, related_memo_id, type)
);
--- attachment
-CREATE TABLE attachment (
+-- resource
+CREATE TABLE resource (
id SERIAL PRIMARY KEY,
uid TEXT NOT NULL UNIQUE,
creator_id INTEGER NOT NULL,
diff --git a/store/migration/sqlite/0.26/01__rename_system_setting_to_instance_setting.sql b/store/migration/sqlite/0.26/01__rename_system_setting_to_instance_setting.sql
deleted file mode 100644
index 84ed64a1b..000000000
--- a/store/migration/sqlite/0.26/01__rename_system_setting_to_instance_setting.sql
+++ /dev/null
@@ -1 +0,0 @@
-ALTER TABLE `system_setting` RENAME TO `instance_setting`;
diff --git a/store/migration/sqlite/LATEST.sql b/store/migration/sqlite/LATEST.sql
index b3a26d29d..6a36e9338 100644
--- a/store/migration/sqlite/LATEST.sql
+++ b/store/migration/sqlite/LATEST.sql
@@ -1,5 +1,5 @@
--- instance_setting
-CREATE TABLE instance_setting (
+-- system_setting
+CREATE TABLE system_setting (
name TEXT NOT NULL,
value TEXT NOT NULL,
description TEXT NOT NULL DEFAULT '',
@@ -63,8 +63,8 @@ CREATE TABLE memo_relation (
UNIQUE(memo_id, related_memo_id, type)
);
--- attachment
-CREATE TABLE attachment (
+-- resource
+CREATE TABLE resource (
id INTEGER PRIMARY KEY AUTOINCREMENT,
uid TEXT NOT NULL UNIQUE,
creator_id INTEGER NOT NULL,
@@ -80,9 +80,9 @@ CREATE TABLE attachment (
payload TEXT NOT NULL DEFAULT '{}'
);
-CREATE INDEX idx_attachment_creator_id ON attachment (creator_id);
+CREATE INDEX idx_resource_creator_id ON resource (creator_id);
-CREATE INDEX idx_attachment_memo_id ON attachment (memo_id);
+CREATE INDEX idx_resource_memo_id ON resource (memo_id);
-- activity
CREATE TABLE activity (
diff --git a/store/test/migrator_test.go b/store/test/migrator_test.go
index ce510d503..946d9ce10 100644
--- a/store/test/migrator_test.go
+++ b/store/test/migrator_test.go
@@ -13,5 +13,5 @@ func TestGetCurrentSchemaVersion(t *testing.T) {
currentSchemaVersion, err := ts.GetCurrentSchemaVersion()
require.NoError(t, err)
- require.Equal(t, "0.26.2", currentSchemaVersion)
+ require.Equal(t, "0.26.1", currentSchemaVersion)
}