27 lines
519 B
JavaScript
Raw Normal View History

2021-05-18 10:16:03 +02:00
'use strict';
2021-06-02 15:53:22 +02:00
const createSchemaBuilder = require('./builder');
2021-05-18 10:16:03 +02:00
const createSchemaProvider = db => {
/*
1. Load schema from DB
3. Run migrations on old schema
2. Build new schema
4. Diff the two
5. Apply diff
*/
2021-06-02 15:53:22 +02:00
return {
get builder() {
return createSchemaBuilder(db);
},
async sync() {
// TODO: sync schema instead of creating it
await this.builder.dropSchema();
await this.builder.createSchema();
},
};
2021-05-18 10:16:03 +02:00
};
module.exports = createSchemaProvider;