From dd80d5af9edf04033c149c46383f224d7bc9be81 Mon Sep 17 00:00:00 2001 From: Jan Eitzinger Date: Thu, 29 Jun 2023 14:55:38 +0200 Subject: [PATCH] Change config value datatype Fixes #167 --- internal/repository/migration.go | 2 +- .../repository/migrations/mysql/06_change-config.down.sql | 1 + internal/repository/migrations/mysql/06_change-config.up.sql | 1 + .../repository/migrations/sqlite3/06_change-config.down.sql | 4 ++++ .../repository/migrations/sqlite3/06_change-config.up.sql | 4 ++++ 5 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 internal/repository/migrations/mysql/06_change-config.down.sql create mode 100644 internal/repository/migrations/mysql/06_change-config.up.sql create mode 100644 internal/repository/migrations/sqlite3/06_change-config.down.sql create mode 100644 internal/repository/migrations/sqlite3/06_change-config.up.sql diff --git a/internal/repository/migration.go b/internal/repository/migration.go index a5605c6..0f37d0a 100644 --- a/internal/repository/migration.go +++ b/internal/repository/migration.go @@ -16,7 +16,7 @@ import ( "github.com/golang-migrate/migrate/v4/source/iofs" ) -const Version uint = 5 +const Version uint = 6 //go:embed migrations/* var migrationFiles embed.FS diff --git a/internal/repository/migrations/mysql/06_change-config.down.sql b/internal/repository/migrations/mysql/06_change-config.down.sql new file mode 100644 index 0000000..0651790 --- /dev/null +++ b/internal/repository/migrations/mysql/06_change-config.down.sql @@ -0,0 +1 @@ +ALTER TABLE configuration MODIFY value VARCHAR(255); diff --git a/internal/repository/migrations/mysql/06_change-config.up.sql b/internal/repository/migrations/mysql/06_change-config.up.sql new file mode 100644 index 0000000..e35ff19 --- /dev/null +++ b/internal/repository/migrations/mysql/06_change-config.up.sql @@ -0,0 +1 @@ +ALTER TABLE configuration MODIFY value TEXT; diff --git a/internal/repository/migrations/sqlite3/06_change-config.down.sql b/internal/repository/migrations/sqlite3/06_change-config.down.sql new file mode 100644 index 0000000..74a8299 --- /dev/null +++ b/internal/repository/migrations/sqlite3/06_change-config.down.sql @@ -0,0 +1,4 @@ +ALTER TABLE configuration ADD COLUMN value_new varchar(255); +INSERT INTO configuration (value_new) SELECT value FROM configuration; +ALTER TABLE configuration DROP COLUMN value; +ALTER TABLE configuration RENAME COLUMN value_new TO value; diff --git a/internal/repository/migrations/sqlite3/06_change-config.up.sql b/internal/repository/migrations/sqlite3/06_change-config.up.sql new file mode 100644 index 0000000..0dae70c --- /dev/null +++ b/internal/repository/migrations/sqlite3/06_change-config.up.sql @@ -0,0 +1,4 @@ +ALTER TABLE configuration ADD COLUMN value_new TEXT; +INSERT INTO configuration (value_new) SELECT value FROM configuration; +ALTER TABLE configuration DROP COLUMN value; +ALTER TABLE configuration RENAME COLUMN value_new TO value;