Browse Source

* Potential updated updated fix for #6

pull/10/head
Per-Arne 5 years ago
parent
commit
04f654e111
  1. 16
      wg_dashboard_backend/main.py

16
wg_dashboard_backend/main.py

@ -38,13 +38,6 @@ if not database_exists(engine.url):
# Create database from metadata
models.Base.metadata.create_all(engine)
# Do migrations
try:
main(["version_control", DATABASE_URL, "migrations"])
except DatabaseAlreadyControlledError:
pass
main(["upgrade", DATABASE_URL, "migrations"])
# Create default user
_db.add(models.User(
username=os.getenv("ADMIN_USERNAME", "admin"),
@ -55,6 +48,15 @@ if not database_exists(engine.url):
))
_db.commit()
# Do migrations
try:
main(["version_control", DATABASE_URL, "migrations"])
except DatabaseAlreadyControlledError:
pass
main(["upgrade", DATABASE_URL, "migrations"])
servers: typing.List[models.WGServer] = _db.query(models.WGServer).all()
for s in servers:
try:

Loading…
Cancel
Save