stripe / pg-schema-diff

Go library for diffing Postgres schemas and generating SQL migrations
MIT License
316 stars 23 forks source link

Online foreign key support #141

Closed bplunkett-stripe closed 1 month ago

bplunkett-stripe commented 2 months ago

Description

Online foreign key support via VALIDATE.

Unfortunately, it is not possible to add NOT VALID constraints to partitioned tables, so this strategy can only work when adding foreign keys to normal tables. It does work on partitions, so if a user really wanted to add foreign key constraints safely on a partitioned table, they could just add n foreign key constraints, one per partition, rather than just 1.

Motivation

Fixes #97

Testing

Tested via acceptance tests