1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-01-11 18:13:52 +02:00

Add remove templates channel link migration (#3794)

This commit is contained in:
Miguel de la Cruz 2022-09-07 22:22:06 +02:00 committed by GitHub
parent d1346be051
commit 7ebcdf59c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 0 deletions

View File

@ -0,0 +1 @@
UPDATE {{.prefix}}boards SET channel_id = '' WHERE is_template;

View File

@ -0,0 +1,5 @@
INSERT INTO focalboard_boards
(id, title, type, is_template, channel_id, team_id)
VALUES
('board-id', 'Board', 'O', false, 'linked-channel', 'team-id'),
('template-id', 'Template', 'O', true, 'linked-channel', 'team-id');

View File

@ -0,0 +1,55 @@
package migrationstests
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test28RemoveTemplateChannelLink(t *testing.T) {
t.Run("should correctly remove the channel link from templates", func(t *testing.T) {
th, tearDown := SetupTestHelper(t)
defer tearDown()
th.f.MigrateToStep(27).
ExecFile("./fixtures/test28RemoveTemplateChannelLink.sql")
// first we check that the data has the expected shape
board := struct {
ID string
Is_template bool
Channel_id string
}{}
template := struct {
ID string
Is_template bool
Channel_id string
}{}
bErr := th.f.DB().Get(&board, "SELECT id, is_template, channel_id FROM focalboard_boards WHERE id = 'board-id'")
require.NoError(t, bErr)
require.False(t, board.Is_template)
require.Equal(t, "linked-channel", board.Channel_id)
tErr := th.f.DB().Get(&template, "SELECT id, is_template, channel_id FROM focalboard_boards WHERE id = 'template-id'")
require.NoError(t, tErr)
require.True(t, template.Is_template)
require.Equal(t, "linked-channel", template.Channel_id)
// we apply the migration
th.f.MigrateToStep(28)
// then we reuse the structs to load again the data and check
// that the changes were correctly applied
bErr = th.f.DB().Get(&board, "SELECT id, is_template, channel_id FROM focalboard_boards WHERE id = 'board-id'")
require.NoError(t, bErr)
require.False(t, board.Is_template)
require.Equal(t, "linked-channel", board.Channel_id)
tErr = th.f.DB().Get(&template, "SELECT id, is_template, channel_id FROM focalboard_boards WHERE id = 'template-id'")
require.NoError(t, tErr)
require.True(t, template.Is_template)
require.Empty(t, template.Channel_id)
})
}