Fix schema storage

This commit is contained in:
Alexandre Bodin 2021-09-20 09:12:23 +02:00
parent 0d9ba0e5fd
commit 59eb3990dd
3 changed files with 8 additions and 4 deletions

View File

@ -1,6 +1,6 @@
'use strict'; 'use strict';
const createSchemaDiff = require('../schema-diff'); const createSchemaDiff = require('../diff');
let diffSchemas; let diffSchemas;
describe('diffSchemas', () => { describe('diffSchemas', () => {

View File

@ -49,8 +49,6 @@ const createSchemaProvider = db => {
const { status, diff } = this.schemaDiff.diff(DBSchema, schema); const { status, diff } = this.schemaDiff.diff(DBSchema, schema);
console.log(diff.tables.updated.flatMap(t => t.columns.updated).map(x => x.object));
if (status === 'CHANGED') { if (status === 'CHANGED') {
await this.builder.updateSchema(diff); await this.builder.updateSchema(diff);
} }
@ -81,6 +79,7 @@ const createSchemaProvider = db => {
if (oldHash !== hash) { if (oldHash !== hash) {
debug('Schema changed'); debug('Schema changed');
return this.syncSchema(); return this.syncSchema();
} }

View File

@ -36,7 +36,12 @@ module.exports = db => {
return null; return null;
} }
return typeof res.schema === 'object' ? res.schema : JSON.parse(res.schema); const parsedSchema = typeof res.schema === 'object' ? res.schema : JSON.parse(res.schema);
return {
...res,
schema: parsedSchema,
};
}, },
hashSchema(schema) { hashSchema(schema) {