|
|
@ -112,7 +112,9 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr { |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
for (const {meta, id, title, schema_previous} of metas) { |
|
|
|
for (const {meta, id, title, |
|
|
|
|
|
|
|
// schema_previous
|
|
|
|
|
|
|
|
} of metas) { |
|
|
|
const metaObj = JSON.parse(meta); |
|
|
|
const metaObj = JSON.parse(meta); |
|
|
|
/* filter relation where this table is present */ |
|
|
|
/* filter relation where this table is present */ |
|
|
|
const hasMany = metaObj.hasMany.filter(({enabled}) => enabled) |
|
|
|
const hasMany = metaObj.hasMany.filter(({enabled}) => enabled) |
|
|
@ -127,15 +129,15 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr { |
|
|
|
const newSchema = this.schemas[title] = GqlXcSchemaFactory.create(this.connectionConfig, this.generateRendererArgs(ctx)).getString(); |
|
|
|
const newSchema = this.schemas[title] = GqlXcSchemaFactory.create(this.connectionConfig, this.generateRendererArgs(ctx)).getString(); |
|
|
|
if (oldSchema !== this.schemas[title]) { |
|
|
|
if (oldSchema !== this.schemas[title]) { |
|
|
|
// keep upto 5 schema backup on table update
|
|
|
|
// keep upto 5 schema backup on table update
|
|
|
|
let previousSchemas = [oldSchema] |
|
|
|
// const previousSchemas = [oldSchema]
|
|
|
|
if (schema_previous) { |
|
|
|
// if (schema_previous) {
|
|
|
|
previousSchemas = [...JSON.parse(schema_previous), oldSchema].slice(-5); |
|
|
|
// previousSchemas = [...JSON.parse(schema_previous), oldSchema].slice(-5);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
this.log(`onToggleModelRelation : Updating and taking backup of schema for '%s' table`, title) |
|
|
|
this.log(`onToggleModelRelation : Updating and taking backup of schema for '%s' table`, title) |
|
|
|
|
|
|
|
|
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
schema: newSchema, |
|
|
|
schema: newSchema, |
|
|
|
schema_previous: JSON.stringify(previousSchemas) |
|
|
|
// schema_previous: JSON.stringify(previousSchemas)
|
|
|
|
}, { |
|
|
|
}, { |
|
|
|
id |
|
|
|
id |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1523,19 +1525,19 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr { |
|
|
|
if (oldSchema !== this.schemas[tn]) { |
|
|
|
if (oldSchema !== this.schemas[tn]) { |
|
|
|
this.log(`onTableUpdate : Updating and taking backup of schema - '%s' table`, changeObj.tn); |
|
|
|
this.log(`onTableUpdate : Updating and taking backup of schema - '%s' table`, changeObj.tn); |
|
|
|
|
|
|
|
|
|
|
|
const oldModel = await this.xcMeta.metaGet(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
// const oldModel = await this.xcMeta.metaGet(this.projectId, this.dbAlias, 'nc_models', {
|
|
|
|
title: tn |
|
|
|
// title: tn
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// keep upto 5 schema backup on table update
|
|
|
|
// keep upto 5 schema backup on table update
|
|
|
|
let previousSchemas = [oldSchema] |
|
|
|
// let previousSchemas = [oldSchema]
|
|
|
|
if (oldModel.schema_previous) { |
|
|
|
// if (oldModel.schema_previous) {
|
|
|
|
previousSchemas = [...JSON.parse(oldModel.schema_previous), oldSchema].slice(-5); |
|
|
|
// previousSchemas = [...JSON.parse(oldModel.schema_previous), oldSchema].slice(-5);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
schema: this.schemas[tn], |
|
|
|
schema: this.schemas[tn], |
|
|
|
schema_previous: JSON.stringify(previousSchemas) |
|
|
|
// schema_previous: JSON.stringify(previousSchemas)
|
|
|
|
}, { |
|
|
|
}, { |
|
|
|
title: tn |
|
|
|
title: tn |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1567,19 +1569,19 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr { |
|
|
|
|
|
|
|
|
|
|
|
this.log(`onViewUpdate : Updating and taking backup of schema - '%s' view`, viewName); |
|
|
|
this.log(`onViewUpdate : Updating and taking backup of schema - '%s' view`, viewName); |
|
|
|
|
|
|
|
|
|
|
|
const oldModel = await this.xcMeta.metaGet(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
// const oldModel = await this.xcMeta.metaGet(this.projectId, this.dbAlias, 'nc_models', {
|
|
|
|
title: viewName |
|
|
|
// title: viewName
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// keep upto 5 schema backup on table update
|
|
|
|
// // keep upto 5 schema backup on table update
|
|
|
|
let previousSchemas = [oldSchema] |
|
|
|
// let previousSchemas = [oldSchema]
|
|
|
|
if (oldModel.schema_previous) { |
|
|
|
// if (oldModel.schema_previous) {
|
|
|
|
previousSchemas = [...JSON.parse(oldModel.schema_previous), oldSchema].slice(-5); |
|
|
|
// previousSchemas = [...JSON.parse(oldModel.schema_previous), oldSchema].slice(-5);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
schema: meta.schema, |
|
|
|
schema: meta.schema, |
|
|
|
schema_previous: JSON.stringify(previousSchemas) |
|
|
|
// schema_previous: JSON.stringify(previousSchemas)
|
|
|
|
}, { |
|
|
|
}, { |
|
|
|
title: viewName |
|
|
|
title: viewName |
|
|
|
}); |
|
|
|
}); |
|
|
@ -1641,19 +1643,19 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr { |
|
|
|
const newSchemaa = GqlXcSchemaFactory.create(this.connectionConfig, this.generateRendererArgs(ctx)).getString(); |
|
|
|
const newSchemaa = GqlXcSchemaFactory.create(this.connectionConfig, this.generateRendererArgs(ctx)).getString(); |
|
|
|
|
|
|
|
|
|
|
|
if (newSchemaa !== this.schemas[tn]) { |
|
|
|
if (newSchemaa !== this.schemas[tn]) { |
|
|
|
const oldModel = await this.xcMeta.metaGet(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
// const oldModel = await this.xcMeta.metaGet(this.projectId, this.dbAlias, 'nc_models', {
|
|
|
|
title: tn |
|
|
|
// title: tn
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
this.log(`onToggleModels : Updating and taking backup of schema for '%s'`, tn); |
|
|
|
// this.log(`onToggleModels : Updating and taking backup of schema for '%s'`, tn);
|
|
|
|
let previousSchemas = [this.schemas[tn]]; |
|
|
|
// let previousSchemas = [this.schemas[tn]];
|
|
|
|
if (oldModel.schema_previous) { |
|
|
|
// if (oldModel.schema_previous) {
|
|
|
|
previousSchemas = [...JSON.parse(oldModel.schema_previous), [this.schemas[tn]]].slice(-5); |
|
|
|
// previousSchemas = [...JSON.parse(oldModel.schema_previous), [this.schemas[tn]]].slice(-5);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
this.schemas[tn] = newSchemaa; |
|
|
|
this.schemas[tn] = newSchemaa; |
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
schema: this.schemas[tn], |
|
|
|
schema: this.schemas[tn], |
|
|
|
schema_previous: JSON.stringify(previousSchemas) |
|
|
|
// schema_previous: JSON.stringify(previousSchemas)
|
|
|
|
}, { |
|
|
|
}, { |
|
|
|
title: tn |
|
|
|
title: tn |
|
|
|
}) |
|
|
|
}) |
|
|
@ -2019,19 +2021,19 @@ export class GqlApiBuilder extends BaseApiBuilder<Noco> implements XcMetaMgr { |
|
|
|
if (oldSchema !== this.schemas[tn]) { |
|
|
|
if (oldSchema !== this.schemas[tn]) { |
|
|
|
// this.log(`onTableUpdate : Updating and taking backup of schema - '%s' table`, tn);
|
|
|
|
// this.log(`onTableUpdate : Updating and taking backup of schema - '%s' table`, tn);
|
|
|
|
|
|
|
|
|
|
|
|
const oldModel = await this.xcMeta.metaGet(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
// const oldModel = await this.xcMeta.metaGet(this.projectId, this.dbAlias, 'nc_models', {
|
|
|
|
title: tn |
|
|
|
// title: tn
|
|
|
|
}); |
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
// keep upto 5 schema backup on table update
|
|
|
|
// // keep upto 5 schema backup on table update
|
|
|
|
let previousSchemas = [oldSchema] |
|
|
|
// let previousSchemas = [oldSchema]
|
|
|
|
if (oldModel.schema_previous) { |
|
|
|
// if (oldModel.schema_previous) {
|
|
|
|
previousSchemas = [...JSON.parse(oldModel.schema_previous), oldSchema].slice(-5); |
|
|
|
// previousSchemas = [...JSON.parse(oldModel.schema_previous), oldSchema].slice(-5);
|
|
|
|
} |
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
schema: this.schemas[tn], |
|
|
|
schema: this.schemas[tn], |
|
|
|
schema_previous: JSON.stringify(previousSchemas) |
|
|
|
// schema_previous: JSON.stringify(previousSchemas)
|
|
|
|
}, { |
|
|
|
}, { |
|
|
|
title: tn, |
|
|
|
title: tn, |
|
|
|
type: 'table' |
|
|
|
type: 'table' |
|
|
|