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

Function MigrateDown

internal/storage/migration.go:147–176  ·  view source on GitHub ↗

MigrateDown undoes all database migrations, reverting the schema to the initial state.

(engine, uri string)

Source from the content-addressed store, hash-verified

145
146// MigrateDown undoes all database migrations, reverting the schema to the initial state.
147func MigrateDown(engine, uri string) (err error) {
148 switch engine {
149 case database.POSTGRES.String():
150 var db *PQDatabase.Postgres
151 db, err = PQDatabase.New(uri)
152 if err != nil {
153 return err
154 }
155 defer closeDB(db)
156
157 goose.SetTableName(migrationsTable)
158
159 if err = goose.SetDialect(postgresDialect); err != nil {
160 return err
161 }
162
163 goose.SetBaseFS(postgresMigrations)
164 pool := stdlib.OpenDBFromPool(db.WritePool)
165
166 if err = goose.Down(pool, postgresMigrationDir); err != nil {
167 return err
168 }
169
170 return nil
171 case database.MEMORY.String():
172 return nil
173 default:
174 return fmt.Errorf("%s connection is unsupported", engine)
175 }
176}
177
178// MigrateDownTo undoes database migrations down to a specific version.
179func MigrateDownTo(engine, uri string, p int64) (err error) {

Callers 1

migrateDownFunction · 0.92

Calls 2

closeDBFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected