aquametalabs / aquameta

Web development platform built entirely in PostgreSQL
GNU General Public License v3.0
1.1k stars 52 forks source link

bundle: Make circular foreign keys in bundle.commit DEFERRABLE #259

Closed erichanson closed 9 months ago

erichanson commented 1 year ago

The bundle.bundle and bundle.commit tables have circular foreign keys. Each commit is part of a particular bundle (commit.bundle_id) but each bundle also has a head_commit_id and checkout_commit_id. This is logically correct but makes loading data into these tables difficult. Work around this by making the fk constraints on head_commit_id and checkout_commit_id DEFERRABLE INITIALLY DEFERRED.

erichanson commented 9 months ago

This has been done for a while.