Skip to content

Commit d75de89

Browse files
authored
fix: use mysql json default as expression (#1048)
1 parent e1e5828 commit d75de89

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

internal/database/migrations/mysql/0001_initial_account.up.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CREATE TABLE IF NOT EXISTS account(
33
username VARCHAR(250) NOT NULL,
44
password BINARY(80) NOT NULL,
55
owner TINYINT(1) NOT NULL DEFAULT '0',
6-
config JSON NOT NULL DEFAULT '{}',
6+
config JSON NOT NULL DEFAULT ('{}'),
77
PRIMARY KEY (id),
88
UNIQUE KEY account_username_UNIQUE (username))
99
CHARACTER SET utf8mb4;

internal/database/mysql.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ var mysqlMigrations = []migration{
4848
}
4949
defer tx.Rollback()
5050

51-
_, err = tx.Exec(`ALTER TABLE account ADD COLUMN config JSON NOT NULL DEFAULT '{}'`)
51+
_, err = tx.Exec(`ALTER TABLE account ADD COLUMN config JSON NOT NULL DEFAULT ('{}')`)
5252
if err != nil && strings.Contains(err.Error(), `Duplicate column name`) {
5353
tx.Rollback()
5454
} else if err != nil {

0 commit comments

Comments
 (0)