Commit cc9a214b authored by Johnny's avatar Johnny

revert: revert system_setting to instance_setting rename changes

Reverts only the system_setting → instance_setting rename related changes from commit d326c710.
Keeps the resource → attachment rename changes intact.

- Reverts table name back to system_setting in all database drivers (MySQL, PostgreSQL, SQLite)
- Removes migration files for the system_setting rename
- Reverts LATEST.sql files to use system_setting table
parent e75862de
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
) )
func (d *DB) UpsertInstanceSetting(ctx context.Context, upsert *store.InstanceSetting) (*store.InstanceSetting, error) { 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( _, err := d.db.ExecContext(
ctx, ctx,
stmt, stmt,
...@@ -31,7 +31,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS ...@@ -31,7 +31,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS
where, args = append(where, "`name` = ?"), append(args, find.Name) 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...) rows, err := d.db.QueryContext(ctx, query, args...)
if err != nil { if err != nil {
return nil, err return nil, err
...@@ -59,7 +59,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS ...@@ -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 { 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) _, err := d.db.ExecContext(ctx, stmt, delete.Name)
return err return err
} }
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
func (d *DB) UpsertInstanceSetting(ctx context.Context, upsert *store.InstanceSetting) (*store.InstanceSetting, error) { func (d *DB) UpsertInstanceSetting(ctx context.Context, upsert *store.InstanceSetting) (*store.InstanceSetting, error) {
stmt := ` stmt := `
INSERT INTO instance_setting ( INSERT INTO system_setting (
name, value, description name, value, description
) )
VALUES ($1, $2, $3) VALUES ($1, $2, $3)
...@@ -36,7 +36,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS ...@@ -36,7 +36,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS
name, name,
value, value,
description description
FROM instance_setting FROM system_setting
WHERE ` + strings.Join(where, " AND ") WHERE ` + strings.Join(where, " AND ")
rows, err := d.db.QueryContext(ctx, query, args...) rows, err := d.db.QueryContext(ctx, query, args...)
...@@ -66,7 +66,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS ...@@ -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 { 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) _, err := d.db.ExecContext(ctx, stmt, delete.Name)
return err return err
} }
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
func (d *DB) UpsertInstanceSetting(ctx context.Context, upsert *store.InstanceSetting) (*store.InstanceSetting, error) { func (d *DB) UpsertInstanceSetting(ctx context.Context, upsert *store.InstanceSetting) (*store.InstanceSetting, error) {
stmt := ` stmt := `
INSERT INTO instance_setting ( INSERT INTO system_setting (
name, value, description name, value, description
) )
VALUES (?, ?, ?) VALUES (?, ?, ?)
...@@ -36,7 +36,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS ...@@ -36,7 +36,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS
name, name,
value, value,
description description
FROM instance_setting FROM system_setting
WHERE ` + strings.Join(where, " AND ") WHERE ` + strings.Join(where, " AND ")
rows, err := d.db.QueryContext(ctx, query, args...) rows, err := d.db.QueryContext(ctx, query, args...)
...@@ -66,7 +66,7 @@ func (d *DB) ListInstanceSettings(ctx context.Context, find *store.FindInstanceS ...@@ -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 { 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) _, err := d.db.ExecContext(ctx, stmt, delete.Name)
return err return err
} }
-- instance_setting -- system_setting
CREATE TABLE `instance_setting` ( CREATE TABLE `system_setting` (
`name` VARCHAR(256) NOT NULL PRIMARY KEY, `name` VARCHAR(256) NOT NULL PRIMARY KEY,
`value` LONGTEXT NOT NULL, `value` LONGTEXT NOT NULL,
`description` TEXT NOT NULL `description` TEXT NOT NULL
...@@ -58,8 +58,8 @@ CREATE TABLE `memo_relation` ( ...@@ -58,8 +58,8 @@ CREATE TABLE `memo_relation` (
UNIQUE(`memo_id`,`related_memo_id`,`type`) UNIQUE(`memo_id`,`related_memo_id`,`type`)
); );
-- attachment -- resource
CREATE TABLE `resource` (
`id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
`uid` VARCHAR(256) NOT NULL UNIQUE, `uid` VARCHAR(256) NOT NULL UNIQUE,
`creator_id` INT NOT NULL, `creator_id` INT NOT NULL,
......
-- instance_setting -- system_setting
CREATE TABLE instance_setting ( CREATE TABLE system_setting (
name TEXT NOT NULL PRIMARY KEY, name TEXT NOT NULL PRIMARY KEY,
value TEXT NOT NULL, value TEXT NOT NULL,
description TEXT NOT NULL description TEXT NOT NULL
...@@ -58,8 +58,8 @@ CREATE TABLE memo_relation ( ...@@ -58,8 +58,8 @@ CREATE TABLE memo_relation (
UNIQUE(memo_id, related_memo_id, type) UNIQUE(memo_id, related_memo_id, type)
); );
-- attachment -- resource
CREATE TABLE resource (
id SERIAL PRIMARY KEY, id SERIAL PRIMARY KEY,
uid TEXT NOT NULL UNIQUE, uid TEXT NOT NULL UNIQUE,
creator_id INTEGER NOT NULL, creator_id INTEGER NOT NULL,
......
ALTER TABLE `system_setting` RENAME TO `instance_setting`;
-- instance_setting -- system_setting
CREATE TABLE instance_setting ( CREATE TABLE system_setting (
name TEXT NOT NULL, name TEXT NOT NULL,
value TEXT NOT NULL, value TEXT NOT NULL,
description TEXT NOT NULL DEFAULT '', description TEXT NOT NULL DEFAULT '',
...@@ -63,8 +63,8 @@ CREATE TABLE memo_relation ( ...@@ -63,8 +63,8 @@ CREATE TABLE memo_relation (
UNIQUE(memo_id, related_memo_id, type) UNIQUE(memo_id, related_memo_id, type)
); );
-- attachment -- resource
CREATE TABLE resource (
id INTEGER PRIMARY KEY AUTOINCREMENT, id INTEGER PRIMARY KEY AUTOINCREMENT,
uid TEXT NOT NULL UNIQUE, uid TEXT NOT NULL UNIQUE,
creator_id INTEGER NOT NULL, creator_id INTEGER NOT NULL,
...@@ -80,9 +80,9 @@ CREATE TABLE attachment ( ...@@ -80,9 +80,9 @@ CREATE TABLE attachment (
payload TEXT NOT NULL DEFAULT '{}' 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 -- activity
CREATE TABLE activity ( CREATE TABLE activity (
......
...@@ -13,5 +13,5 @@ func TestGetCurrentSchemaVersion(t *testing.T) { ...@@ -13,5 +13,5 @@ func TestGetCurrentSchemaVersion(t *testing.T) {
currentSchemaVersion, err := ts.GetCurrentSchemaVersion() currentSchemaVersion, err := ts.GetCurrentSchemaVersion()
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, "0.26.2", currentSchemaVersion) require.Equal(t, "0.26.1", currentSchemaVersion)
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment