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

Function MigrateStatus

internal/storage/migration.go:243–272  ·  view source on GitHub ↗

MigrateStatus displays the status of all migrations.

(engine, uri string)

Source from the content-addressed store, hash-verified

241
242// MigrateStatus displays the status of all migrations.
243func MigrateStatus(engine, uri string) (err error) {
244 switch engine {
245 case database.POSTGRES.String():
246 var db *PQDatabase.Postgres
247 db, err = PQDatabase.New(uri)
248 if err != nil {
249 return err
250 }
251 defer closeDB(db)
252
253 goose.SetTableName(migrationsTable)
254
255 if err = goose.SetDialect(postgresDialect); err != nil {
256 return err
257 }
258
259 goose.SetBaseFS(postgresMigrations)
260 pool := stdlib.OpenDBFromPool(db.WritePool)
261
262 if err = goose.Status(pool, postgresMigrationDir); err != nil {
263 return err
264 }
265
266 return nil
267 case database.MEMORY.String():
268 return nil
269 default:
270 return fmt.Errorf("%s connection is unsupported", engine)
271 }
272}
273
274// closeDB cleanly closes the database connection and logs if an error occurs.
275func closeDB(db *PQDatabase.Postgres) {

Callers 1

migrateStatusFunction · 0.92

Calls 2

closeDBFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected