mirror of
https://github.com/coder/coder.git
synced 2025-07-13 21:36:50 +00:00
fix(coderd): remove CREATE INDEX CONCURRENTLY
from migrations (#8353)
This commit is contained in:
@ -1 +1 @@
|
|||||||
CREATE INDEX CONCURRENTLY workspace_resources_job_id_idx ON workspace_resources USING btree (job_id);
|
CREATE INDEX workspace_resources_job_id_idx ON workspace_resources USING btree (job_id);
|
||||||
|
@ -20,6 +20,7 @@ import (
|
|||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"go.uber.org/goleak"
|
"go.uber.org/goleak"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
|
"golang.org/x/sync/errgroup"
|
||||||
|
|
||||||
"github.com/coder/coder/coderd/database/migrations"
|
"github.com/coder/coder/coderd/database/migrations"
|
||||||
"github.com/coder/coder/coderd/database/postgres"
|
"github.com/coder/coder/coderd/database/postgres"
|
||||||
@ -47,6 +48,22 @@ func TestMigrate(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("Parallel", func(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
db := testSQLDB(t)
|
||||||
|
eg := errgroup.Group{}
|
||||||
|
|
||||||
|
eg.Go(func() error {
|
||||||
|
return migrations.Up(db)
|
||||||
|
})
|
||||||
|
eg.Go(func() error {
|
||||||
|
return migrations.Up(db)
|
||||||
|
})
|
||||||
|
|
||||||
|
require.NoError(t, eg.Wait())
|
||||||
|
})
|
||||||
|
|
||||||
t.Run("Twice", func(t *testing.T) {
|
t.Run("Twice", func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@ -86,6 +103,13 @@ func testSQLDB(t testing.TB) *sql.DB {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
t.Cleanup(func() { _ = db.Close() })
|
t.Cleanup(func() { _ = db.Close() })
|
||||||
|
|
||||||
|
// postgres.Open automatically runs migrations, but we want to actually test
|
||||||
|
// migration behavior in this package.
|
||||||
|
_, err = db.Exec(`DROP SCHEMA public CASCADE`)
|
||||||
|
require.NoError(t, err)
|
||||||
|
_, err = db.Exec(`CREATE SCHEMA public`)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
return db
|
return db
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user