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

Reconsider using nullable over not_null #491

Open
andrew-farries opened this issue Nov 26, 2024 · 1 comment
Open

Reconsider using nullable over not_null #491

andrew-farries opened this issue Nov 26, 2024 · 1 comment
Labels
breaking-changes breaking changes to pgroll
Milestone

Comments

@andrew-farries
Copy link
Collaborator

In #132 it was decided to use nullable over not_null to set column nullability in create_table, add_column and alter_column operations, for example:

{
  "name": "03_add_column_to_products",
  "operations": [
    {
      "add_column": {
        "table": "products",
        "up": "UPPER(name)",
        "column": {
          "name": "description",
          "type": "varchar(255)",
          "nullable": true
        }
      }
    }
  ]
}

As a breaking change before v1 we should consider whether we want to reverse this decision and use not_null instead.

Using not_null is less surprising as columns in Postgres are nullable by default, whereas by using nullable's implicit default of false we reverse this expectation.

@andrew-farries andrew-farries added the breaking-changes breaking changes to pgroll label Nov 26, 2024
@andrew-farries andrew-farries added this to the v1 milestone Nov 26, 2024
@exekias
Copy link
Member

exekias commented Nov 26, 2024

this is entirely on me 🙏 , but I agree not_null is much better! btw, to do this backward compatible we could allow both nullable and not_null (but not both at the same time, at least if their values disagree) today. Then deprecate nullable with 1.0.

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

No branches or pull requests

2 participants