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

Purpose of drop_column down is unclear in the documentation #257

Open
simonw opened this issue Jan 30, 2024 · 1 comment
Open

Purpose of drop_column down is unclear in the documentation #257

simonw opened this issue Jan 30, 2024 · 1 comment

Comments

@simonw
Copy link

simonw commented Jan 30, 2024

This section here:

https://github.com/xataio/pgroll/blob/9d2515963865ba4b5b71fe0ff9ea85e8ce9e2ddf/docs/README.md#drop-column

A drop column operation drops a column from an existing table.

drop column operations have this structure:

{
   "drop_column": {
    "table": "name of table",
    "column": "name of column to drop",
    "down": "SQL expression"
  }
}

It's not obvious to me what the "down" key here is used for.

@exekias
Copy link
Member

exekias commented Jan 31, 2024

Thank you for opening this issue!

Down migrations are applied to adapt data from the latest schema version into the previous one. During the active migration period, you will have a new schema version that doesn't have the column, while the old schema (that has it) is still available.

If the deployed version of your application expects a value in that column (or there is a constraint requiring it, ie NOT NULL), down function can be used to ensure that all inserts/updates happening in the new version of the schema get a valid value backfilled into this column for the old version of the schema (and its clients) to consume.

Hope this clarifies things? I realize docs may need some more explanation, we can use this issue to ensure we update them!

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

No branches or pull requests

2 participants