Skip to content

Commit

Permalink
refactor: isolate migration and metadata application
Browse files Browse the repository at this point in the history
This is to avoid rolling back migrations when only the
metadata application fails on startup.
  • Loading branch information
rhyslbw committed Jan 25, 2021
1 parent d774879 commit d314c62
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion packages/api-cardano-db-hasura/src/HasuraClient.ts
Expand Up @@ -83,12 +83,18 @@ export class HasuraClient {
await pRetry(async () => {
await this.hasuraCli('migrate apply --down all')
await this.hasuraCli('migrate apply --up all')
}, {
factor: 1.75,
retries: 9,
onFailedAttempt: util.onFailedAttemptFor('Applying PostgreSQL schema migrations')
})
await pRetry(async () => {
await this.hasuraCli('metadata clear')
await this.hasuraCli('metadata apply')
}, {
factor: 1.75,
retries: 9,
onFailedAttempt: util.onFailedAttemptFor('Applying PostgreSQL schema and Hasura metadata')
onFailedAttempt: util.onFailedAttemptFor('Applying Hasura metadata')
})
this.applyingSchemaAndMetadata = false
}
Expand Down

0 comments on commit d314c62

Please sign in to comment.