-
Notifications
You must be signed in to change notification settings - Fork 74
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 support for exclusion constraints in create_table
operation
#624
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 👍
I wonder whether we can do without the need for the btree_gist
extension though.
.github/workflows/build.yml
Outdated
@@ -220,6 +220,7 @@ jobs: | |||
if [ "$PGROLL_SCHEMA" != "public" ]; then | |||
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -c "CREATE SCHEMA $PGROLL_SCHEMA;" | |||
fi | |||
psql -h $POSTGRES_HOST -p $POSTGRES_PORT -U postgres -c "CREATE EXTENSION IF NOT EXISTS btree_gist SCHEMA $PGROLL_SCHEMA;" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to make a similar change to the local docker compose
setup too:
docker compose up
make examples
now fails because the btree_gist
extension isn't installed.
@@ -0,0 +1,56 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to give an example migration that doesn't require the btree_gist
extension?
All the example migrations so far run against a vanilla Postgres - this is the first one that requires an extension.
@@ -1020,6 +1020,191 @@ func TestCreateTable(t *testing.T) { | |||
}, rows) | |||
}, | |||
}, | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could potentially just keep the first of these tests, which wouldn't require the extension.
Do you think that still provides enough coverage?
I think the simple test provides enough coverage already. I am happy to remove the more complex tests. \o/ |
This PR adds a new type of constraint to
create_table
operation calledexclude
to support exclusion constraints.New options:
exclude.index_method
: name of the index method (e.g. btree, gist, etc.)exclude.elements
: exlusion elementsexclude.predicate
: WHERE clause for partial indicesExample constraint forbidding overlap in room reservations:
The tests I added require the extension
btree_gist
. So I added it formake examples
and runninggo test
.