diff options
| author | Frederick Muriuki Muriithi | 2026-04-07 13:53:21 -0500 |
|---|---|---|
| committer | Frederick Muriuki Muriithi | 2026-04-07 13:54:01 -0500 |
| commit | b2e870ccb3cd82f8ba28a578144c20fa6a636221 (patch) | |
| tree | a5bde141875d7c7bcdf6563ed1dec2c7deb5e2c2 | |
| parent | 5e4f320440f4cb49ebc61b286a1baebc5f66740f (diff) | |
| download | gn-auth-b2e870ccb3cd82f8ba28a578144c20fa6a636221.tar.gz | |
Handle edge case where no admins exist: e.g. database is empty.
| -rw-r--r-- | migrations/auth/20260402_01_Bf8nm-add-user-and-time-tracking-to-resources-table.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/migrations/auth/20260402_01_Bf8nm-add-user-and-time-tracking-to-resources-table.py b/migrations/auth/20260402_01_Bf8nm-add-user-and-time-tracking-to-resources-table.py index fd1e617..702c418 100644 --- a/migrations/auth/20260402_01_Bf8nm-add-user-and-time-tracking-to-resources-table.py +++ b/migrations/auth/20260402_01_Bf8nm-add-user-and-time-tracking-to-resources-table.py @@ -38,7 +38,9 @@ def fetch_a_sysadmin_id(conn, resources_table): return tuple(row[0] for row in cursor.fetchall()) if not bool(__admin_id__): - __admin_id__ = random.choice(__fetch__()) + __admins__ = __fetch__() + if len(__admins__) > 0: + __admin_id__ = random.choice(__admins__) return __admin_id__ |
