Commit 812f0b90 authored by EKbfh's avatar EKbfh 🐼
Browse files

Add migration 39

parent e9df427c
Pipeline #28514 passed with stages
in 2 minutes and 42 seconds
# Third-party modules
import yaml
import json
from peewee import (Model, CharField, TextField, BooleanField)
from peewee import (Model, CharField, TextField, ForeignKeyField)
def migrate(migrator):
......@@ -39,18 +40,15 @@ def migrate(migrator):
config = TextField()
pool = ForeignKeyField(Pool, null=True)
node = ForeignKeyField(Node)
n_instances = IntegerField(default=0)
n_backup_instances = IntegerField(default=0)
for env in Environment.select():
print("Migrating %s" % env.name)
for Service.select(environment=env)
if Service.service == "login"
print
conf = yaml.full_load(env.service_config)
if "session_ttl" in config[None]["login"]:
if "d" not in str(config[None]["login"]["session_ttl"]):
config[None]["login"]["session_ttl"] = str(config[None]["login"]["session_ttl"]) + "d"
env.service_config = yaml.dump(config)
env.save()
if len(Environment.select()) != 0:
for env in Environment.select():
print("Migrating %s" % env.name)
s = Service.select().where(Service.environment == env.id,
Service.service == "login")
conf = yaml.full_load(s[0].config)
if "session_ttl" in conf:
if "d" not in str(conf["session_ttl"]):
conf["session_ttl"] = str(conf["session_ttl"]) + "d"
s[0].config = json.dumps(conf, sort_keys=True)
s[0].save()
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment