MCPcopy Create free account
hub / github.com/Permify/permify / MigrateUp

Function MigrateUp

internal/storage/migration.go:83–112  ·  view source on GitHub ↗

MigrateUp performs all available database migrations to update the schema to the latest version.

(engine, uri string)

Source from the content-addressed store, hash-verified

81
82// MigrateUp performs all available database migrations to update the schema to the latest version.
83func MigrateUp(engine, uri string) (err error) {
84 switch engine {
85 case database.POSTGRES.String():
86 var db *PQDatabase.Postgres
87 db, err = PQDatabase.New(uri)
88 if err != nil {
89 return err
90 }
91 defer closeDB(db)
92
93 goose.SetTableName(migrationsTable)
94
95 if err = goose.SetDialect(postgresDialect); err != nil {
96 return err
97 }
98
99 goose.SetBaseFS(postgresMigrations)
100 pool := stdlib.OpenDBFromPool(db.WritePool)
101
102 if err = goose.Up(pool, postgresMigrationDir); err != nil {
103 return err
104 }
105
106 return nil
107 case database.MEMORY.String():
108 return nil
109 default:
110 return fmt.Errorf("%s connection is unsupported", engine)
111 }
112}
113
114// MigrateUpTo performs database migrations up to a specific version.
115func MigrateUpTo(engine, uri string, p int64) (err error) {

Callers 1

migrateUpFunction · 0.92

Calls 2

closeDBFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected