Commit b0119f32 authored by johnnyjoy's avatar johnnyjoy

chore: tweak migration scripts

parent 5e770dda
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
// Version is the service current released version. // Version is the service current released version.
// Semantic versioning: https://semver.org/ // Semantic versioning: https://semver.org/
var Version = "0.23.1" var Version = "0.24.0"
// DevVersion is the service current development version. // DevVersion is the service current development version.
var DevVersion = "0.24.0" var DevVersion = "0.24.0"
......
-- Drop deprecated tags column. -- Drop deprecated tags column.
ALTER TABLE `memo` DROP COLUMN `tags`; ALTER TABLE `memo` DROP COLUMN `tags`;
\ No newline at end of file
-- Add pinned column.
ALTER TABLE `memo` ADD COLUMN `pinned` BOOLEAN NOT NULL DEFAULT FALSE;
-- Update pinned column from memo_organizer.
UPDATE `memo`
SET `pinned` = TRUE
FROM `memo_organizer`
WHERE `memo`.`id` = `memo_organizer`.`memo_id` AND `memo_organizer`.`pinned` = 1;
\ No newline at end of file
-- Add pinned column.
ALTER TABLE `memo` ADD COLUMN `pinned` BOOLEAN NOT NULL DEFAULT FALSE;
-- Update pinned column from memo_organizer.
UPDATE `memo`
SET `pinned` = TRUE
FROM `memo_organizer`
WHERE `memo`.`id` = `memo_organizer`.`memo_id` AND `memo_organizer`.`pinned` = 1;
\ No newline at end of file
-- Drop deprecated tags column. -- Drop deprecated tags column.
ALTER TABLE memo DROP COLUMN tags; ALTER TABLE memo DROP COLUMN tags;
\ No newline at end of file
-- Add pinned column.
ALTER TABLE memo ADD COLUMN pinned BOOLEAN NOT NULL DEFAULT FALSE;
-- Update pinned column from memo_organizer.
UPDATE memo
SET pinned = TRUE
FROM memo_organizer
WHERE memo.id = memo_organizer.memo_id AND memo_organizer.pinned = 1;
\ No newline at end of file
-- Add pinned column.
ALTER TABLE memo ADD COLUMN pinned BOOLEAN NOT NULL DEFAULT FALSE;
-- Update pinned column from memo_organizer.
UPDATE memo
SET pinned = TRUE
FROM memo_organizer
WHERE memo.id = memo_organizer.memo_id AND memo_organizer.pinned = 1;
\ No newline at end of file
...@@ -4,13 +4,4 @@ ALTER TABLE memo DROP COLUMN tags; ...@@ -4,13 +4,4 @@ ALTER TABLE memo DROP COLUMN tags;
-- Remove deprecated indexes. -- Remove deprecated indexes.
DROP INDEX IF EXISTS idx_memo_tags; DROP INDEX IF EXISTS idx_memo_tags;
DROP INDEX IF EXISTS idx_memo_content; DROP INDEX IF EXISTS idx_memo_content;
DROP INDEX IF EXISTS idx_memo_visibility; DROP INDEX IF EXISTS idx_memo_visibility;
\ No newline at end of file
-- Add pinned column.
ALTER TABLE memo ADD COLUMN pinned INTEGER NOT NULL CHECK (pinned IN (0, 1)) DEFAULT 0;
-- Update pinned column from memo_organizer.
UPDATE memo
SET pinned = 1
FROM memo_organizer
WHERE memo.id = memo_organizer.memo_id AND memo_organizer.pinned = 1;
\ No newline at end of file
-- Add pinned column.
ALTER TABLE memo ADD COLUMN pinned INTEGER NOT NULL CHECK (pinned IN (0, 1)) DEFAULT 0;
-- Update pinned column from memo_organizer.
UPDATE memo
SET pinned = 1
FROM memo_organizer
WHERE memo.id = memo_organizer.memo_id AND memo_organizer.pinned = 1;
\ No newline at end of file
...@@ -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.23.1", currentSchemaVersion) require.Equal(t, "0.24.2", 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