mirror of https://github.com/coder/coder.git
fix(coderd): remove `CREATE INDEX CONCURRENTLY` from migrations (#8353)
This commit is contained in:
parent
2ebd0ec6c5
commit
9a0ba1bdc3
|
@ -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"
|
||||
"go.uber.org/goleak"
|
||||
"golang.org/x/exp/slices"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
||||
"github.com/coder/coder/coderd/database/migrations"
|
||||
"github.com/coder/coder/coderd/database/postgres"
|
||||
|
@ -47,6 +48,22 @@ func TestMigrate(t *testing.T) {
|
|||
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.Parallel()
|
||||
|
||||
|
@ -86,6 +103,13 @@ func testSQLDB(t testing.TB) *sql.DB {
|
|||
require.NoError(t, err)
|
||||
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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue