1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! Strategy for pre-existing duplicates when adding a UNIQUE constraint to
//! an existing column.
//!
//! `AddConstraint(Unique)` against a populated column would fail at apply
//! time when duplicate values exist. Vespertide treats this as a fault
//! the user must resolve explicitly: every revision that adds UNIQUE on
//! an existing column emits a `DELETE` ahead of the `ADD CONSTRAINT`,
//! keeping one row per group based on the strategy below.
//!
//! There is no "skip cleanup" option — relying on the database to reject
//! the migration is incompatible with vespertide's safety promise. Users
//! who *know* their data is clean still get the same SQL: `DELETE` on
//! a clean table is a no-op.
//!
//! `#[non_exhaustive]` so additional strategies (e.g. `KeepWithExpression`
//! when single-column-PK is insufficient) can be added in a future minor
//! release without breaking downstream `match`es.
use ;
/// How `AddConstraint(Unique)` should handle pre-existing duplicate rows.
/// Which row of a duplicate group is kept when `DeleteDuplicates` runs.
///
/// "First" / "Last" are defined by the table's PRIMARY KEY ordering:
/// `First = MIN(pk)`, `Last = MAX(pk)`. Requires a single-column PK.