0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/migrations/tooling/lib
Gerhard Schlager 67e987c1f5 MT: Let a generated model declare its conflict strategy in the schema DSL
The per-table merge policy reads `conflict_strategy` off each model, but only
the hand-written `upload` model could declare it — a generated model always got
a plain `INSERT` because the generator has no notion of a conflict clause.

This adds a `conflict_strategy :ignore` directive to the table DSL and threads it
through to `ModelWriter`, so a generated model can opt into `INSERT OR IGNORE`:
the writer emits both the `OR IGNORE` SQL and a `self.conflict_strategy` method,
which is what `IntermediateDB.conflict_strategy_for` reads at run time.

It defaults to `:raise` and only emits anything for `:ignore`, so every existing
generated model regenerates byte-for-byte. No table uses it yet — `uploads` stays
a manual model — but the option now lives in the schema config where the rest of
a table's shape is declared.
2026-07-03 17:05:25 +02:00
..
migrations MT: Let a generated model declare its conflict strategy in the schema DSL 2026-07-03 17:05:25 +02:00
migrations-tooling.rb