Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Manage migrations with postgres-migrations #507

Merged
merged 30 commits into from
May 18, 2021

Conversation

nunopato
Copy link
Contributor

@nunopato nunopato commented May 4, 2021

HBP-specific migrations (auth) are currently being managed by Hasura, which makes it hard to release schema changes to auth. This PR adds postgres-migrations so that HBP manages its own migrations/schemas.

  • DB related migrations live now inside ./db
  • When HBP starts, it runs any new migrations in ./db/migrations - migrations here should be specific to the auth schema.
  • The file ./db/00_init-schema.sql creates extensions and the auth schema (not the tables) and it is used with docker-entrypoint-initdb when creating the DB the first time - this initialization will soon be moved to http://github.com/nhost/postgres.

The metadata is still managed by Hasura and lives in ./db/hasura/metadata.

@nunopato nunopato changed the title [WIP] Introduce migrations to hbp [WIP] Manage migrations with postgres-migrations May 4, 2021
@komninoschatzipapas
Copy link
Contributor

This will also close #354.

@nunopato nunopato changed the title [WIP] Manage migrations with postgres-migrations Manage migrations with postgres-migrations May 12, 2021
@nunopato nunopato requested review from komninoschatzipapas and elitan and removed request for komninoschatzipapas May 14, 2021 08:51
.github/workflows/build.yml Show resolved Hide resolved
src/migrate.ts Show resolved Hide resolved
@nunopato nunopato merged commit 1601dc3 into master May 18, 2021
@nunopato nunopato deleted the introduce-migrations-to-hbp branch May 18, 2021 14:04
@komninoschatzipapas komninoschatzipapas restored the introduce-migrations-to-hbp branch May 21, 2021 12:04
try {
await client.connect()
await migrate({ client }, './db/migrations')
} finally {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing a catch block

Copy link
Contributor

@elitan elitan May 31, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's by design I think. If the migration fails HBP will fail (and restart) and try to apply the migrations again.

Docker should handle the restart with ex restart: always in docker-compose.

@nunopato Is that correct or are we in fact missing something here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, we want the exception to be thrown and the container fail to start.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants