Read schema after migrations

This commit is contained in:
Alexandre Bodin 2021-09-16 13:37:13 +02:00
parent eef1737acb
commit 76caaba714
2 changed files with 6 additions and 6 deletions

View File

@ -31,7 +31,6 @@ class Dialect {
async startSchemaUpdate() {}
async endSchemaUpdate() {}
// TODO: pass query info to display some more metadata
transformErrors(error) {
if (error instanceof Error) {
throw error;

View File

@ -38,19 +38,20 @@ const createSchemaProvider = db => {
// TODO: support option to disable auto migration & run a CLI command instead to avoid doing it at startup
// TODO: Allow keeping extra indexes / extra tables / extra columns (globally or on a per table basis)
async sync() {
const DBSchema = await db.dialect.schemaInspector.getSchema();
// run migrations
// Run users migrations
db.migration.up();
// diff schema
// Read schema from DB
const DBSchema = await db.dialect.schemaInspector.getSchema();
// Diff schema
const { status, diff } = this.schemaDiff.diff(DBSchema, schema);
if (status === 'UNCHANGED') {
return;
}
// update schema
// Update schema
await this.builder.updateSchema(diff);
},
};