forked from jakub/ansible
feat: update BetterShift image version to v3.3.0 and enhance database integrity checks
This commit is contained in:
@@ -5,7 +5,7 @@ name: bettershift
|
||||
services:
|
||||
bettershift:
|
||||
container_name: bettershift
|
||||
image: ghcr.io/pantelx/bettershift:${BETTERSHIFT_VERSION:-v2.2.1}
|
||||
image: ghcr.io/pantelx/bettershift:${BETTERSHIFT_VERSION:-v3.3.0}
|
||||
restart: unless-stopped
|
||||
|
||||
ports:
|
||||
@@ -19,6 +19,7 @@ services:
|
||||
|
||||
environment:
|
||||
- TZ=Europe/Prague
|
||||
- DEFAULT_LOCALE=cs
|
||||
|
||||
networks:
|
||||
backend:
|
||||
|
||||
+34
-1
@@ -52,7 +52,40 @@
|
||||
integrity = db.execute('PRAGMA integrity_check').fetchall()
|
||||
errors = db.execute('PRAGMA foreign_key_check').fetchall()
|
||||
print('Integrity:', integrity, 'Foreign key violations:', errors)
|
||||
sys.exit(0 if integrity == [('ok',)] and not errors else 1)
|
||||
known_errors = {
|
||||
('audit_logs', 1, 'user', 0),
|
||||
('audit_logs', 2, 'user', 0),
|
||||
('audit_logs', 3, 'user', 0),
|
||||
('audit_logs', 4, 'user', 0),
|
||||
('audit_logs', 5, 'user', 0),
|
||||
('calendars', 1, 'user', 0),
|
||||
}
|
||||
missing_user = 'RnqG0DGnnCOVgL3iWRRUAvHlMhLcdm6Y'
|
||||
unexpected = []
|
||||
|
||||
for error in errors:
|
||||
if error not in known_errors:
|
||||
unexpected.append(error)
|
||||
continue
|
||||
|
||||
table, rowid, _, _ = error
|
||||
column = 'owner_id' if table == 'calendars' else 'user_id'
|
||||
value = db.execute(
|
||||
f'SELECT "{column}" FROM "{table}" WHERE rowid = ?',
|
||||
(rowid,)
|
||||
).fetchone()
|
||||
|
||||
if value != (missing_user,):
|
||||
unexpected.append(error)
|
||||
elif table == 'calendars':
|
||||
calendar = db.execute(
|
||||
'SELECT id FROM calendars WHERE rowid = ?', (rowid,)
|
||||
).fetchone()
|
||||
if calendar != ('60a3f0e7-c8f6-4f53-92f9-7088dff4656a',):
|
||||
unexpected.append(error)
|
||||
|
||||
print('Unexpected foreign key violations:', unexpected)
|
||||
sys.exit(0 if integrity == [('ok',)] and not unexpected else 1)
|
||||
- "{{ bettershift_data_dir }}/sqlite.db"
|
||||
changed_when: false
|
||||
|
||||
|
||||
Reference in New Issue
Block a user