activerecord-cockroachdb-adapter icon indicating copy to clipboard operation
activerecord-cockroachdb-adapter copied to clipboard

fix: Avoid dumping unique_constraint when attisdropped

Open BuonOmo opened this issue 1 year ago • 1 comments

Fixes #347

BuonOmo avatar Oct 16 '24 15:10 BuonOmo

Columns with the UNIQUE constraint automatically have an index created with the name <table name>_<columns>_key. To avoid having two identical indexes, you should not create indexes that exactly match the UNIQUE constraint's columns and order.

(https://www.cockroachlabs.com/docs/stable/unique)

I think we can just consider every unique_constraint as an index then.

The UNIQUE constraint depends on the automatically created index, so dropping the index also drops the UNIQUE constraint. Conversely, dropping the UNIQUE constraint also drops the automatically created index.

BuonOmo avatar Oct 24 '24 11:10 BuonOmo