Commit 1e62f64
feat(migrate): physical index/constraint attrs + auto schema-scope + adoption fixes
Enables non-destructive adoption of an existing Postgres database (verify --db /
migrate --from-db reaching zero drift against a hand-built schema) and richer index
modeling. All physical-storage concerns are contributed by the db provider
(spec/metamodel/db.json `extends`), not core.
db provider — new physical attrs on core identity subtypes:
- identity.secondary @orders — per-key sort direction (asc|desc) → DESC index keys
- identity.secondary @where — partial-index predicate → WHERE (<pred>)
- identity.reference @constraintName — FK constraint-name override (adopt an
existing DB's naming without a rename)
Wired end-to-end: IndexDescriptor {orders?, where?}, buildSecondaryIndexes,
renderCreateIndex (DESC + WHERE), readPgIndexes (indoption + pg_get_expr(indpred);
expression-key indexes skipped), indexEquals (positional orders + normalized
predicate). FkDescriptor honours @constraintName.
diff — auto schema scope (DiffArgs.scopeSchemas):
the diff manages only the schemas the expected/metadata side declares; a table in
an undeclared schema belongs to another owner and is left untouched. Makes
per-owner drift gates clean with no manual config; an explicit set overrides; an
empty model preserves prior whole-DB behavior.
introspect — gen_random_uuid() classified as an expression default:
parsePgDefault now treats any bare function-call default as an expression (mirrors
the metadata-side EXPR_DEFAULT_PATTERNS), so a uuid-PK column round-trips without a
spurious default diff.
fix(metadata) — allowedValues on an isArray attr validates each ELEMENT, not the
array as a whole (previously always failed; @orders is the first isArray+allowedValues
attr).
Tests: index-partial-ordered, diff-schema-scope, expected-schema-fk-constraint-name,
isArray-allowedValues cases; updated diff-schema-aware + identity/coverage gates;
regenerated the embedded metamodel, registry manifest, metamodel docs, and Python
spec copies. metadata + migrate-ts suites green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>1 parent f0d2fa6 commit 1e62f64
21 files changed
Lines changed: 727 additions & 110 deletions
File tree
- fixtures
- metamodel-docs/expected
- types
- registry-conformance
- server
- python/src/metaobjects/spec_metamodel
- typescript/packages
- metadata
- src
- core/identity
- persistence/db
- test
- migrate-ts
- src
- diff
- emit
- introspect
- test
- spec/metamodel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
| 40 | + | |
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
| |||
56 | 57 | | |
57 | 58 | | |
58 | 59 | | |
| 60 | + | |
59 | 61 | | |
| 62 | + | |
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
28 | 27 | | |
29 | 28 | | |
30 | 29 | | |
31 | 30 | | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | 31 | | |
36 | | - | |
37 | 32 | | |
38 | 33 | | |
39 | | - | |
40 | 34 | | |
41 | 35 | | |
42 | 36 | | |
43 | 37 | | |
44 | 38 | | |
45 | 39 | | |
46 | 40 | | |
47 | | - | |
48 | | - | |
49 | 41 | | |
50 | 42 | | |
51 | 43 | | |
52 | 44 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | 45 | | |
57 | | - | |
58 | 46 | | |
59 | 47 | | |
60 | | - | |
61 | 48 | | |
62 | 49 | | |
63 | 50 | | |
| |||
71 | 58 | | |
72 | 59 | | |
73 | 60 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | 61 | | |
78 | | - | |
79 | 62 | | |
80 | 63 | | |
81 | | - | |
82 | 64 | | |
83 | 65 | | |
84 | 66 | | |
85 | 67 | | |
86 | 68 | | |
87 | 69 | | |
88 | 70 | | |
89 | | - | |
90 | 71 | | |
91 | 72 | | |
92 | 73 | | |
93 | 74 | | |
94 | 75 | | |
95 | | - | |
96 | | - | |
97 | 76 | | |
98 | 77 | | |
99 | 78 | | |
100 | | - | |
101 | 79 | | |
102 | 80 | | |
103 | 81 | | |
104 | 82 | | |
105 | 83 | | |
106 | 84 | | |
107 | 85 | | |
108 | | - | |
109 | 86 | | |
110 | 87 | | |
111 | 88 | | |
112 | 89 | | |
113 | 90 | | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 91 | | |
118 | | - | |
119 | 92 | | |
120 | 93 | | |
121 | | - | |
122 | 94 | | |
123 | 95 | | |
124 | 96 | | |
125 | 97 | | |
126 | 98 | | |
127 | 99 | | |
128 | 100 | | |
129 | | - | |
130 | 101 | | |
131 | 102 | | |
132 | 103 | | |
133 | 104 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | 105 | | |
138 | | - | |
139 | 106 | | |
140 | 107 | | |
141 | | - | |
142 | 108 | | |
143 | 109 | | |
144 | 110 | | |
145 | 111 | | |
146 | 112 | | |
147 | 113 | | |
148 | 114 | | |
149 | | - | |
150 | 115 | | |
151 | 116 | | |
152 | 117 | | |
153 | 118 | | |
154 | 119 | | |
155 | 120 | | |
156 | | - | |
157 | | - | |
158 | | - | |
159 | 121 | | |
160 | | - | |
161 | 122 | | |
162 | 123 | | |
163 | | - | |
164 | 124 | | |
165 | 125 | | |
166 | 126 | | |
167 | 127 | | |
168 | 128 | | |
169 | 129 | | |
170 | 130 | | |
171 | | - | |
172 | 131 | | |
173 | 132 | | |
174 | 133 | | |
175 | 134 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | 135 | | |
181 | | - | |
182 | 136 | | |
183 | 137 | | |
184 | 138 | | |
185 | 139 | | |
186 | 140 | | |
187 | 141 | | |
188 | 142 | | |
189 | | - | |
190 | 143 | | |
191 | 144 | | |
192 | 145 | | |
193 | 146 | | |
194 | 147 | | |
195 | | - | |
196 | | - | |
197 | | - | |
198 | | - | |
199 | 148 | | |
200 | | - | |
201 | 149 | | |
202 | 150 | | |
203 | 151 | | |
204 | 152 | | |
205 | 153 | | |
206 | 154 | | |
207 | 155 | | |
208 | | - | |
209 | 156 | | |
210 | 157 | | |
211 | 158 | | |
212 | 159 | | |
213 | 160 | | |
214 | | - | |
215 | | - | |
216 | 161 | | |
217 | 162 | | |
218 | | - | |
219 | 163 | | |
220 | 164 | | |
221 | 165 | | |
| |||
225 | 169 | | |
226 | 170 | | |
227 | 171 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | 172 | | |
232 | | - | |
233 | 173 | | |
234 | 174 | | |
235 | 175 | | |
| |||
243 | 183 | | |
244 | 184 | | |
245 | 185 | | |
246 | | - | |
247 | | - | |
248 | | - | |
249 | 186 | | |
250 | | - | |
251 | 187 | | |
252 | 188 | | |
253 | | - | |
254 | 189 | | |
255 | 190 | | |
256 | 191 | | |
| |||
263 | 198 | | |
264 | 199 | | |
265 | 200 | | |
266 | | - | |
267 | | - | |
268 | | - | |
269 | | - | |
270 | 201 | | |
271 | | - | |
272 | 202 | | |
273 | 203 | | |
274 | 204 | | |
275 | 205 | | |
276 | 206 | | |
277 | 207 | | |
278 | 208 | | |
279 | | - | |
280 | 209 | | |
281 | 210 | | |
282 | 211 | | |
283 | 212 | | |
284 | 213 | | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | 214 | | |
289 | | - | |
290 | 215 | | |
291 | 216 | | |
292 | | - | |
293 | 217 | | |
294 | 218 | | |
295 | 219 | | |
296 | 220 | | |
297 | | - | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
298 | 228 | | |
299 | | - | |
300 | | - | |
| 229 | + | |
| 230 | + | |
301 | 231 | | |
302 | 232 | | |
303 | 233 | | |
304 | 234 | | |
305 | 235 | | |
306 | | - | |
307 | | - | |
308 | 236 | | |
309 | 237 | | |
310 | 238 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2014 | 2014 | | |
2015 | 2015 | | |
2016 | 2016 | | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
| 2021 | + | |
| 2022 | + | |
| 2023 | + | |
2017 | 2024 | | |
2018 | 2025 | | |
2019 | 2026 | | |
| |||
2050 | 2057 | | |
2051 | 2058 | | |
2052 | 2059 | | |
| 2060 | + | |
| 2061 | + | |
| 2062 | + | |
| 2063 | + | |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
2053 | 2067 | | |
2054 | 2068 | | |
2055 | 2069 | | |
2056 | 2070 | | |
2057 | 2071 | | |
2058 | 2072 | | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
2059 | 2080 | | |
2060 | 2081 | | |
2061 | 2082 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
41 | 56 | | |
42 | 57 | | |
43 | 58 | | |
Lines changed: 12 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
251 | 251 | | |
252 | 252 | | |
253 | 253 | | |
254 | | - | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
255 | 257 | | |
256 | | - | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
257 | 265 | | |
258 | 266 | | |
259 | 267 | | |
260 | | - | |
261 | | - | |
| 268 | + | |
| 269 | + | |
262 | 270 | | |
263 | 271 | | |
264 | 272 | | |
| |||
0 commit comments