Skip to content

Commit 9a0ba1b

Browse files
authored
fix(coderd): remove CREATE INDEX CONCURRENTLY from migrations (#8353)
1 parent 2ebd0ec commit 9a0ba1b

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
CREATE INDEX CONCURRENTLY workspace_resources_job_id_idx ON workspace_resources USING btree (job_id);
1+
CREATE INDEX workspace_resources_job_id_idx ON workspace_resources USING btree (job_id);

coderd/database/migrations/migrate_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"github.com/stretchr/testify/require"
2121
"go.uber.org/goleak"
2222
"golang.org/x/exp/slices"
23+
"golang.org/x/sync/errgroup"
2324

2425
"github.com/coder/coder/coderd/database/migrations"
2526
"github.com/coder/coder/coderd/database/postgres"
@@ -47,6 +48,22 @@ func TestMigrate(t *testing.T) {
4748
require.NoError(t, err)
4849
})
4950

51+
t.Run("Parallel", func(t *testing.T) {
52+
t.Parallel()
53+
54+
db := testSQLDB(t)
55+
eg := errgroup.Group{}
56+
57+
eg.Go(func() error {
58+
return migrations.Up(db)
59+
})
60+
eg.Go(func() error {
61+
return migrations.Up(db)
62+
})
63+
64+
require.NoError(t, eg.Wait())
65+
})
66+
5067
t.Run("Twice", func(t *testing.T) {
5168
t.Parallel()
5269

@@ -86,6 +103,13 @@ func testSQLDB(t testing.TB) *sql.DB {
86103
require.NoError(t, err)
87104
t.Cleanup(func() { _ = db.Close() })
88105

106+
// postgres.Open automatically runs migrations, but we want to actually test
107+
// migration behavior in this package.
108+
_, err = db.Exec(`DROP SCHEMA public CASCADE`)
109+
require.NoError(t, err)
110+
_, err = db.Exec(`CREATE SCHEMA public`)
111+
require.NoError(t, err)
112+
89113
return db
90114
}
91115

0 commit comments

Comments
 (0)