Commit 7b90f45
authored
fix: Allow multiple accounts per (party, org, instrument) - unblock nightly Demo Reset (#2174)
* fix: Allow multiple accounts per (party, org, instrument) for multi-service billing
Drops idx_account_syndicate_scope_integrity, the unique partial index on
(party_id, org_party_id, instrument_code) introduced in PRD-022. The original
constraint modelled a syndicate where each participant holds one position per
currency in a venture, but it does not match utility billing patterns where a
single customer legitimately holds separate billing accounts of the same
instrument with the same supplier (e.g. PPM-ELEC-CUST001 and PPM-GAS-CUST001
under the same supplier party for Margaret Thornton in the PAYG demo).
This has caused the nightly Demo Reset workflow to fail since the PAYG Energy
tenant was added on 2026-03-27 (#1963). With the index removed, account
uniqueness is still enforced by idx_account_account_identification, so the
constraint relaxation does not allow accidental duplication; it only allows
the legitimate multi-service-per-supplier pattern.
Updates the org-scoped migration test to assert the new behaviour (multiple
GBP accounts allowed per party+org, account_identification uniqueness still
enforced).
* test: Tighten duplicate-key assertion to verify constraint name
Per CodeRabbit review: assert.Error alone passes on any insert failure.
Tighten to require the failure references account_identification so the
test specifically proves uniqueness on that column survives dropping the
syndicate scope integrity index.
---------
Co-authored-by: Ben Coombs <bjcoombs@users.noreply.github.com>1 parent bcf27d6 commit 7b90f45
File tree
3 files changed
+62
-12
lines changed- services/current-account
- adapters/persistence
- migrations
3 files changed
+62
-12
lines changedLines changed: 45 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
73 | 73 | | |
74 | 74 | | |
75 | 75 | | |
76 | | - | |
77 | 76 | | |
78 | 77 | | |
79 | 78 | | |
80 | | - | |
81 | 79 | | |
82 | 80 | | |
83 | 81 | | |
| |||
89 | 87 | | |
90 | 88 | | |
91 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
92 | 104 | | |
93 | 105 | | |
94 | 106 | | |
| |||
149 | 161 | | |
150 | 162 | | |
151 | 163 | | |
152 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
153 | 168 | | |
154 | 169 | | |
155 | 170 | | |
156 | 171 | | |
157 | | - | |
158 | 172 | | |
159 | 173 | | |
160 | 174 | | |
161 | | - | |
| 175 | + | |
162 | 176 | | |
163 | 177 | | |
164 | 178 | | |
| |||
172 | 186 | | |
173 | 187 | | |
174 | 188 | | |
175 | | - | |
| 189 | + | |
176 | 190 | | |
177 | | - | |
178 | 191 | | |
179 | 192 | | |
180 | 193 | | |
181 | | - | |
| 194 | + | |
182 | 195 | | |
183 | 196 | | |
184 | 197 | | |
| |||
192 | 205 | | |
193 | 206 | | |
194 | 207 | | |
195 | | - | |
| 208 | + | |
196 | 209 | | |
197 | | - | |
198 | 210 | | |
199 | 211 | | |
200 | 212 | | |
201 | | - | |
| 213 | + | |
202 | 214 | | |
203 | 215 | | |
204 | 216 | | |
| |||
213 | 225 | | |
214 | 226 | | |
215 | 227 | | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
216 | 250 | | |
217 | 251 | | |
218 | 252 | | |
| |||
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
0 commit comments