Skip to content

(Postgresql) Migration applied if the update of the schemaversion table throws an error #110

@p16

Description

@p16

Hi,
I'm running postgrator with postgresql and I found a potential issue when the insert into the schemaversion table fails.

  1. A migration is run and changes the db
  2. The insert fails to update the schemaversion table

I would expect the whole migration to "rollback" but instead I see the migration changes applied and the schemaversion table still pointing to the previous migration as its latest one.

This will cause an error if migrations are run again and they are not idempotent.

I have a branch with a test reproducing this scenario here .

I'm wondering if this scenario is a known edge case and the only solution would be to write idempotent migrations, or if postgrator could support the scenario where both migration and insert are guaranteed to be either "done" or "not done".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions