You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cli): Improves database introspection and syncing
Enhances the `db pull` command with a spinner for better UX.
Adds color-coded logging to highlight important steps.
Provides more detailed output on schema changes, including deleted models, enums, added fields, and deleted attributes.
Also includes minor improvements to enum mapping and constraint handling.
@@ -239,14 +257,16 @@ async function runPull(options: PullOptions) {
239
257
240
258
if(originalFields.length>1){
241
259
console.warn(
242
-
`Found more original fields, need to tweak the search algorith. ${originalDataModel.name}->[${originalFields.map((of)=>of.name).join(', ')}](${f.name})`,
260
+
colors.yellow(
261
+
`Found more original fields, need to tweak the search algorith. ${originalDataModel.name}->[${originalFields.map((of)=>of.name).join(', ')}](${f.name})`,
262
+
),
243
263
);
244
264
return;
245
265
}
246
266
constoriginalField=originalFields.at(0);
247
267
Object.freeze(originalField);
248
268
if(!originalField){
249
-
console.log(`Added field${f.name} to ${originalDataModel.name}`);
269
+
addedFields.push(colors.green(`+ Field${f.name}added to ${originalDataModel.name}`));
250
270
(fasany).$container=originalDataModel;
251
271
originalDataModel.fields.push(fasany);
252
272
if(f.$type==='DataField'&&f.type.reference?.ref){
@@ -260,7 +280,7 @@ async function runPull(options: PullOptions) {
const{ modified, name }=resolveNameCasing(options.modelCasing,dbEnum.enum_type);
41
-
if(modified)console.log(`Mapping enum ${dbEnum.enum_type} to ${name}`);
42
+
if(modified)console.log(colors.gray(`Mapping enum ${dbEnum.enum_type} to ${name}`));
42
43
constfactory=newEnumFactory().setName(name);
43
44
if(modified||options.alwaysMap)
44
45
factory.addAttribute((builder)=>
@@ -344,16 +345,18 @@ export function syncTable({
344
345
table.indexes.forEach((index)=>{
345
346
if(index.predicate){
346
347
//These constraints are not supported by Zenstack, because Zenstack currently does not fully support check constraints. Read more: https://pris.ly/d/check-constraints
347
-
console.log(
348
-
'These constraints are not supported by Zenstack. Read more: https://pris.ly/d/check-constraints',
`These constraints are not supported by Zenstack. Read more: https://pris.ly/d/check-constraints\n- Model: "${table.name}", constraint: "${index.name}"`,
351
+
),
350
352
);
351
353
return;
352
354
}
353
355
if(index.columns.find((c)=>c.expression)){
354
-
console.log(
355
-
'These constraints are not supported by Zenstack. Read more: https://pris.ly/d/check-constraints',
`These constraints are not supported by Zenstack. Read more: https://pris.ly/d/check-constraints\n- Model: "${table.name}", constraint: "${index.name}"`,
0 commit comments