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 14, 2021
1 parent 409615b commit 3663205
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 @@ -82,12 +82,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 3663205

Please sign in to comment.