Commit c9ee003
fix: PR #4039 F1c — MySQL fresh install honors SchemaName end-to-end (builder + V2..V7 ALTERs + detection)
PR #4039 reviewer item M4-1 (comment 4485697019) — MySQL half of F1.
In MySQL "schema" is synonymous with "database". The pre-F1c behaviour:
- MySqlOutboxBuilder / MySqlInboxBuilder GetDDL emitted unqualified
`CREATE TABLE IF NOT EXISTS {table}`, landing the table in DATABASE() (the
connection's bound database).
- V2..V7 ALTERs used unqualified `{table}` and probed
`information_schema.columns WHERE table_schema = DATABASE()`.
- MySqlBoxDetectionHelper used the configured SchemaName for box-table
existence checks AND for the history-table existence check.
When SchemaName != connection.Database (a legitimate multi-tenant scenario),
the box table landed in DATABASE() while detection looked in SchemaName — the
silent split the reviewer flagged. A second run reported "no table" and
re-ran fresh install, producing PK conflicts on history insert.
Fix (Full schema-aware approach per user direction):
1. MySqlOutboxBuilder.GetDDL + MySqlInboxBuilder.GetDDL gain optional
`schemaName` parameter — when non-null, emit `\`schema\`.\`table\`` (backticked);
otherwise unqualified as before.
2. MySqlOutboxMigrationCatalog + MySqlInboxMigrationCatalog:
- FreshInstallDdl threads configuration.SchemaName through to the builder
with defence-in-depth Identifiers.AssertSafe.
- V2..V7 ALTERs (via AddColumn helpers) take an optional `schema` parameter.
When non-null, the table_schema probe filter and the ALTER target are both
schema-qualified; when null, original behaviour (DATABASE() / unqualified)
is preserved bit-for-bit.
3. MySqlBoxDetectionHelper.DoesHistoryExistAsync — the history table itself
always lives in connection.Database (the runner's EnsureHistoryTableAsync
emits unqualified DDL targeting DATABASE()), so the table-existence probe
now uses connection.Database. The schemaName parameter still scopes the
ROW lookup via the SchemaName column filter. Comment updated.
V1HistoricalDdl on both catalogs stays unqualified (historical literal — pre-
SchemaName-era). The unusual chain-bootstrap-at-V1 path with non-default
SchemaName is not exercised in practice; documented constraint.
Integration tests:
- When_mysql_outbox_provisioner_runs_on_fresh_database_with_non_default_schema_it_should_create_in_configured_schema
- When_mysql_inbox_provisioner_runs_on_fresh_database_with_non_default_schema_it_should_create_in_configured_schema
Both pre-create a non-default database, configure SchemaName to it, run the
provisioner twice, and assert (a) table lands in configured database (not
BrighterTests/connection-default), (b) second run is idempotent, (c) history
records exactly one V_latest row. Pre-fix: outbox test failed at "must exist
in 'brighter_billing_*'"; after the builder+ALTER fix, detection bug surfaced
as PK conflict on history insert (second run). Post-detection-fix: both tests
GREEN.
Full MySQL BoxProvisioning suite: 76/76 GREEN net9.0 (+2 vs the 74 post-F2
baseline).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 2c71925 commit c9ee003
7 files changed
Lines changed: 442 additions & 34 deletions
File tree
- src
- Paramore.Brighter.BoxProvisioning.MySql
- Paramore.Brighter.Inbox.MySql
- Paramore.Brighter.Outbox.MySql
- tests/Paramore.Brighter.MySQL.Tests/BoxProvisioning
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
78 | | - | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
79 | 85 | | |
80 | 86 | | |
81 | 87 | | |
82 | 88 | | |
83 | 89 | | |
84 | 90 | | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
85 | 96 | | |
86 | | - | |
| 97 | + | |
87 | 98 | | |
88 | 99 | | |
89 | 100 | | |
| |||
Lines changed: 33 additions & 11 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
96 | 96 | | |
97 | 97 | | |
98 | 98 | | |
99 | | - | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
100 | 112 | | |
101 | 113 | | |
102 | 114 | | |
| |||
107 | 119 | | |
108 | 120 | | |
109 | 121 | | |
| 122 | + | |
110 | 123 | | |
111 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
112 | 129 | | |
113 | 130 | | |
114 | 131 | | |
| |||
121 | 138 | | |
122 | 139 | | |
123 | 140 | | |
124 | | - | |
| 141 | + | |
125 | 142 | | |
126 | 143 | | |
127 | 144 | | |
| |||
137 | 154 | | |
138 | 155 | | |
139 | 156 | | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
145 | 163 | | |
146 | | - | |
147 | | - | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
148 | 169 | | |
149 | | - | |
150 | | - | |
| 170 | + | |
| 171 | + | |
151 | 172 | | |
152 | 173 | | |
153 | 174 | | |
154 | 175 | | |
| 176 | + | |
155 | 177 | | |
Lines changed: 42 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
100 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
101 | 115 | | |
102 | 116 | | |
103 | 117 | | |
| |||
108 | 122 | | |
109 | 123 | | |
110 | 124 | | |
| 125 | + | |
111 | 126 | | |
112 | 127 | | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
113 | 132 | | |
114 | 133 | | |
115 | 134 | | |
| |||
122 | 141 | | |
123 | 142 | | |
124 | 143 | | |
125 | | - | |
| 144 | + | |
126 | 145 | | |
127 | 146 | | |
128 | 147 | | |
129 | 148 | | |
130 | 149 | | |
131 | 150 | | |
132 | | - | |
| 151 | + | |
133 | 152 | | |
134 | 153 | | |
135 | 154 | | |
| |||
139 | 158 | | |
140 | 159 | | |
141 | 160 | | |
142 | | - | |
| 161 | + | |
143 | 162 | | |
144 | 163 | | |
145 | 164 | | |
146 | 165 | | |
147 | 166 | | |
148 | 167 | | |
149 | | - | |
| 168 | + | |
150 | 169 | | |
151 | 170 | | |
152 | 171 | | |
| |||
160 | 179 | | |
161 | 180 | | |
162 | 181 | | |
163 | | - | |
| 182 | + | |
164 | 183 | | |
165 | 184 | | |
166 | 185 | | |
| |||
169 | 188 | | |
170 | 189 | | |
171 | 190 | | |
172 | | - | |
| 191 | + | |
173 | 192 | | |
174 | 193 | | |
175 | 194 | | |
| |||
190 | 209 | | |
191 | 210 | | |
192 | 211 | | |
193 | | - | |
194 | | - | |
| 212 | + | |
| 213 | + | |
195 | 214 | | |
196 | 215 | | |
197 | 216 | | |
198 | | - | |
199 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
200 | 223 | | |
201 | 224 | | |
202 | 225 | | |
203 | 226 | | |
204 | | - | |
205 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
206 | 232 | | |
207 | | - | |
208 | | - | |
| 233 | + | |
| 234 | + | |
209 | 235 | | |
210 | 236 | | |
211 | 237 | | |
212 | 238 | | |
| 239 | + | |
213 | 240 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
79 | 87 | | |
80 | | - | |
| 88 | + | |
81 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
82 | 93 | | |
83 | 94 | | |
84 | | - | |
| 95 | + | |
85 | 96 | | |
86 | 97 | | |
87 | 98 | | |
88 | | - | |
| 99 | + | |
89 | 100 | | |
90 | 101 | | |
91 | | - | |
| 102 | + | |
92 | 103 | | |
93 | 104 | | |
94 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
107 | 116 | | |
108 | | - | |
| 117 | + | |
109 | 118 | | |
110 | 119 | | |
111 | 120 | | |
112 | 121 | | |
113 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
114 | 126 | | |
115 | 127 | | |
116 | 128 | | |
| |||
0 commit comments