remove id migration and directory lookup
This commit is contained in:
parent
9f396acd48
commit
cf3762dd7f
5 changed files with 8 additions and 116 deletions
10
oml/setup.py
10
oml/setup.py
|
|
@ -340,7 +340,13 @@ def upgrade_db(old, new=None):
|
|||
old_key = os.path.join(settings.data_path, 'node.ssl.key')
|
||||
if os.path.exists(old_key):
|
||||
os.unlink(old_key)
|
||||
if settings.OLD_USER_ID:
|
||||
key_path = os.path.join(settings.data_path, 'node.key')
|
||||
if os.path.exists(key_path):
|
||||
import ed25519
|
||||
with open(key_path, 'rb') as fd:
|
||||
sk = ed25519.SigningKey(fd.read())
|
||||
vk = sk.get_verifying_key()
|
||||
OLD_USER_ID = vk.to_ascii(encoding='base64').decode()
|
||||
statements = [
|
||||
"UPDATE user SET id = '{nid}' WHERE id = '{oid}'",
|
||||
"UPDATE list SET user_id = '{nid}' WHERE user_id = '{oid}'",
|
||||
|
|
@ -348,7 +354,7 @@ def upgrade_db(old, new=None):
|
|||
"UPDATE changelog SET user_id = '{nid}' WHERE user_id = '{oid}'",
|
||||
]
|
||||
for sql in statements:
|
||||
run_sql(sql.format(oid=settings.OLD_USER_ID, nid=settings.USER_ID))
|
||||
run_sql(sql.format(oid=OLD_USER_ID, nid=settings.USER_ID))
|
||||
if old <= '20151201-384-03c2439':
|
||||
with db.session():
|
||||
import item.models
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue