Update after testrun
This commit is contained in:
@@ -574,6 +574,21 @@ def add_missing_tables(engine, _session):
|
||||
Thumbnail.__table__.create(bind=engine)
|
||||
|
||||
|
||||
# migrate all settings missing in registration table
|
||||
def migrate_registration_table(engine, _session):
|
||||
try:
|
||||
# Handle table exists, but no content
|
||||
cnt = _session.query(Registration).count()
|
||||
if not cnt:
|
||||
with engine.connect() as conn:
|
||||
trans = conn.begin()
|
||||
conn.execute(text("insert into registration (domain, allow) values('%.%',1)"))
|
||||
trans.commit()
|
||||
except exc.OperationalError: # Database is not writeable
|
||||
print('Settings database is not writeable. Exiting...')
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
def migrate_user_session_table(engine, _session):
|
||||
try:
|
||||
_session.query(exists().where(User_Sessions.random)).scalar()
|
||||
@@ -592,6 +607,7 @@ def migrate_user_session_table(engine, _session):
|
||||
def migrate_Database(_session):
|
||||
engine = _session.bind
|
||||
add_missing_tables(engine, _session)
|
||||
migrate_registration_table(engine, _session)
|
||||
migrate_user_session_table(engine, _session)
|
||||
|
||||
|
||||
@@ -603,6 +619,7 @@ def clean_database(_session):
|
||||
_session.commit()
|
||||
|
||||
|
||||
|
||||
# Save downloaded books per user in calibre-web's own database
|
||||
def update_download(book_id, user_id):
|
||||
check = session.query(Downloads).filter(Downloads.user_id == user_id).filter(Downloads.book_id == book_id).first()
|
||||
|
||||
Reference in New Issue
Block a user