refactor: add schema snapshot by AndrewJackson2020 · Pull Request #66 · supabase/vault · GitHub
Skip to content

refactor: add schema snapshot - #66

Open
AndrewJackson2020 wants to merge 3 commits into
mainfrom
vault_schema_snapshot
Open

AndrewJackson2020 wants to merge 3 commits into
mainfrom
vault_schema_snapshot

Conversation

@AndrewJackson2020

Copy link
Copy Markdown
Contributor

We have moved on from maintaining multiple code path for new installs and migrations in SQL scripts which is nice and less error prone. But what we lose is the ability to diff the extension at a given point in time.

This PR adds a script and CI job that essentially snapshots the state of the extension and records it as text. This is useful because as we saw in pg_net in the past sometimes the incremental migration leads to a different outcome then was expected. For example one of the drifts that occurred in pg_net was dropping a primary key does not drop a null constraint automatically. With a snapshot we maintain the full state in addition to the incremental migration steps.

@AndrewJackson2020
AndrewJackson2020 requested a review from a team as a code owner October 20, 2026 18:51
Comment thread .github/workflows/test.yml Fixed
Comment thread supabase_vault.sql Outdated
Comment on lines +1 to +18

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For better readability I think we should remove the unnecessary SETtings and comments.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately pg_dump doesn't have options for this. Changed the script to output to stdout and then do some piped greg -v filtering. Its not the prettiest but it works.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks much better 👍

@imor

imor commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@AndrewJackson2020 can we add similar checks in other extensions as well if not present.

@AndrewJackson2020

AndrewJackson2020 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor Author

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