revert: revert system_setting to instance_setting rename changes

Reverts only the system_setting → instance_setting rename related changes from commit d326c71.
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
This commit is contained in:
Johnny 2026-01-07 20:38:02 +08:00
parent e75862de31
commit cc9a214be8
10 changed files with 24 additions and 27 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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
}

View File

@ -1 +0,0 @@
RENAME TABLE system_setting TO instance_setting;

View File

@ -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,

View File

@ -1 +0,0 @@
ALTER TABLE system_setting RENAME TO instance_setting;

View File

@ -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,

View File

@ -1 +0,0 @@
ALTER TABLE `system_setting` RENAME TO `instance_setting`;

View File

@ -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 (

View File

@ -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)
}