This commit is contained in:
peter
2019-11-09 11:53:36 +01:00
parent 92824d67a5
commit a7a5a85033
10 changed files with 79 additions and 32 deletions
+13 -6
View File
@@ -146,12 +146,19 @@ implements TableDefinitionExporter {
this.knex = Knex(conf)
await Promise.all(this.getTableDefinitions().map(async (def)=>{
const hasTable = await this.knex.schema.hasTable(def.name)
if(!hasTable){
await this.knex.schema.createTable(def.name, def.tableBuilder)
}
}))
await Promise.all(
this.getTableDefinitions()
//make unique by name
.filter((other, index, self) => index === self.findIndex(
(self) => self.name === other.name)
)
//create table if not exists
.map(async (def)=> {
const hasTable = await this.knex.schema.hasTable(def.name)
if(!hasTable)
return await this.knex.schema.createTable(def.name, def.tableBuilder)
})
)
return this.knex
}