1
0
Fork 0

Upgrade update script

This commit is contained in:
Ethanell 2019-12-25 21:33:52 +01:00
parent 532b153e46
commit 1e3fcfd8a0
3 changed files with 19 additions and 9 deletions

6
.gitignore vendored
View file

@ -5,6 +5,9 @@ venv/
# Logs
logs/
# Calendars
calendars/
# Bot private
edt
edt.*
@ -12,3 +15,6 @@ token.ini
# PyCharm
.idea/
# Alembic
alembic*

View file

@ -1,9 +0,0 @@
import shelve
from base import User
with shelve.open("edt", writeback=True) as db:
for u in db:
nu = User(0, None)
for v in db[u].__dict__:
setattr(nu, v, db[u].__dict__[v])
db[u] = nu

13
update.sh Executable file
View file

@ -0,0 +1,13 @@
#!/bin/bash
if [ -f edt.db ]; then
if [ ! -d alembic ]; then
alembic init alembic
sed -i '/sqlalchemy.url/s/= .*/= sqlite:\/\/\/edt.db/' alembic.ini
sed -i "/target_metadata = None/s/target_metadata.*/import os, sys\nsys.path.append(os.getcwd())\nfrom base import Base\ntarget_metadata = Base.metadata/" alembic/env.py
fi
alembic revision --autogenerate -m "Auto upgrade"
alembic upgrade head
else
echo "No database !"
fi