-
Notifications
You must be signed in to change notification settings - Fork 568
/
clusterstate.go
36 lines (33 loc) · 1.31 KB
/
clusterstate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package v2_7_0
import (
"context"
"github.com/pachyderm/pachyderm/v2/src/internal/errors"
"github.com/pachyderm/pachyderm/v2/src/internal/migrations"
)
func Migrate(state migrations.State) migrations.State {
return state.
Apply("create cluster defaults", func(ctx context.Context, env migrations.Env) error {
return setupPostgresCollections(ctx, env.Tx, ppsCollections()...)
}).
Apply("Create core schema", func(ctx context.Context, env migrations.Env) error {
if err := createCoreSchema(ctx, env.Tx); err != nil {
return errors.Wrap(err, "creating core schema")
}
return nil
}, migrations.Squash).
Apply("Create core.projects table", func(ctx context.Context, env migrations.Env) error {
if err := createProjectsTable(ctx, env.Tx); err != nil {
return errors.Wrap(err, "creating core.projects table")
}
return nil
}, migrations.Squash).
Apply("Migrate collections.projects to core.projects", func(ctx context.Context, env migrations.Env) error {
if err := env.LockTables(ctx, "collections.projects"); err != nil {
return errors.Wrap(err, "acquiring exclusive lock on collections.projects table")
}
if err := migrateProjects(ctx, env.Tx); err != nil {
return errors.Wrap(err, "migrating collections.projects to core.projects")
}
return nil
}, migrations.Squash)
}