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:
parent
d1346be051
commit
7ebcdf59c2
@ -0,0 +1 @@
|
||||
SELECT 1;
|
@ -0,0 +1 @@
|
||||
UPDATE {{.prefix}}boards SET channel_id = '' WHERE is_template;
|
@ -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');
|
@ -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)
|
||||
})
|
||||
}
|
Loading…
Reference in New Issue
Block a user