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

Add --skip-validation flag to start command #448

Merged
merged 2 commits into from
Nov 6, 2024

Conversation

andrew-farries
Copy link
Collaborator

Add a --skip-validation flag to the start command.

If set, migration validation is skipped.

For example, this table has a NOT NULL name field:

{
  "name": "01_create_table",
  "operations": [
    {
      "create_table": {
        "name": "products",
        "columns": [
          {
            "name": "id",
            "type": "serial",
            "pk": true
          },
          {
            "name": "name",
            "type": "varchar(255)",
            "nullable": false
          }
        ]
      }
    }
  ]
}

starting this migration will fail as the name field is already NOT NULL:

{
  "name": "02_set_nullable",
  "operations": [
    {
      "alter_column": {
        "table": "products",
        "column": "name",
        "nullable": false,
        "up": "name",
        "down": "name"
      }
    }
  ]
}
Error: migration is invalid: column "name" on table "products" is NOT NULL

But if the start command is invoked with --skip-validation then the start command succeeds.

This is part of #239

Add support for the `--skip-validation` flag to skip migration
validation.

The flag can also be set using the `PGROLL_SKIP_VALIDATION` environment
variable.
@andrew-farries andrew-farries marked this pull request as ready for review November 6, 2024 08:05
@andrew-farries andrew-farries merged commit 0992c8d into main Nov 6, 2024
27 checks passed
@andrew-farries andrew-farries deleted the add-skip-validate-flag branch November 6, 2024 08:20
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.

3 participants