forked from MapComplete/MapComplete
Scripts: force overwrite the database
This commit is contained in:
parent
b269d210bb
commit
84a2ff5f54
2 changed files with 12 additions and 2 deletions
|
@ -9,8 +9,18 @@ class CreateNewDatabase extends Script {
|
|||
}
|
||||
|
||||
async main(args: string[]): Promise<void> {
|
||||
const targetName = args[0]
|
||||
const overwrite = args[1] === "--overwrite"
|
||||
const db = new OsmPoiDatabase("postgresql://user:password@localhost:5444")
|
||||
await db.createNew(args[0])
|
||||
const knownDatabases = await db.findSuitableDatabases()
|
||||
if (knownDatabases.indexOf(targetName) > 0) {
|
||||
if (overwrite) {
|
||||
await db.deleteDatabase(targetName)
|
||||
} else {
|
||||
throw "ERROR: the target database " + targetName + " already exists"
|
||||
}
|
||||
}
|
||||
await db.createNew(targetName)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue