Preserve login routes across rotation and keep rejected migrations read-only
This commit is contained in:
@@ -96,7 +96,7 @@ class Connection:
|
||||
|
||||
|
||||
class MySQLDatabase(Database):
|
||||
def __init__(self, config):
|
||||
def __init__(self, config, recover_jobs=True):
|
||||
self.config = {key: value for key, value in config.items() if key in ('host', 'port', 'user', 'password', 'database', 'unix_socket')}
|
||||
if not self.config.get('database'):
|
||||
raise ValueError('数据库配置缺少 database')
|
||||
@@ -106,9 +106,10 @@ class MySQLDatabase(Database):
|
||||
conn.execute(statement + ' ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin')
|
||||
if not conn.execute("SHOW COLUMNS FROM jobs LIKE 'resume_pending'").fetchone():
|
||||
conn.execute('ALTER TABLE jobs ADD COLUMN resume_pending TINYINT DEFAULT 0')
|
||||
recovery = "status IN ('running','queued') OR (status='paused' AND resume_pending=1)"
|
||||
self.recovered_job_ids = [row['id'] for row in conn.execute('SELECT id FROM jobs WHERE ' + recovery)]
|
||||
conn.execute("UPDATE jobs SET status='paused',resume_pending=0,message='服务重启,任务可从断点恢复' WHERE " + recovery)
|
||||
if recover_jobs:
|
||||
recovery = "status IN ('running','queued') OR (status='paused' AND resume_pending=1)"
|
||||
self.recovered_job_ids = [row['id'] for row in conn.execute('SELECT id FROM jobs WHERE ' + recovery)]
|
||||
conn.execute("UPDATE jobs SET status='paused',resume_pending=0,message='服务重启,任务可从断点恢复' WHERE " + recovery)
|
||||
|
||||
@contextmanager
|
||||
def connection(self):
|
||||
|
||||
Reference in New Issue
Block a user