rel icon indicating copy to clipboard operation
rel copied to clipboard

sqlite3: persistent Rel.Schema.changes on redundant unique/primary constraints

Open dbuenzli opened this issue 1 year ago • 0 comments

A table definition with a redundant unique/primary keys like:

let table =
  let primary_key = Table.Primary_key.make [Def id'] in
  let unique_keys = [ Table.Unique_key.make [Def id'] ] in
  let indices = [ Table.Index.make [Def id'] ] in
  Table.make "blob" ~primary_key ~unique_keys ~indices @@
  Row.(unit row * id' * media_type' * origin' * public' * slug')

results in always having something in Rel.Schema.changes with a live sqlite3 schema to which this definition is applied. sqlite3 does not seem to record the redundant unique constraint and the changes are always:

ALTER TABLE blob
  ADD UNIQUE KEY (id)

A bit unclear whether we should warn (where ?) at the definition or introduce logic to ignore this on changes.

dbuenzli avatar Oct 12 '24 14:10 dbuenzli