Skip to content

Commit 6f13160

Browse files
authored
fix: Migrating tables (#342)
* fix: Migrating tables - Added exception of exercise - course and number indexes constaint migration - Added exception of usercourse - user and course index constraint migration
1 parent 158ec91 commit 6f13160

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

lms/lmsdb/bootstrap.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,8 @@ def _add_exercise_course_id_and_number_columns_constraint() -> bool:
284284
migrate(
285285
migrator.add_index('exercise', ('course_id', 'number'), True),
286286
)
287-
except OperationalError as e:
288-
if 'already exists' in str(e):
289-
log.info(f'index exercise already exists: {e}')
290-
else:
291-
raise
287+
except (OperationalError, ProgrammingError) as e:
288+
log.info(f'Index exercise course and number already exists: {e}')
292289
db_config.database.commit()
293290

294291

@@ -301,11 +298,8 @@ def _add_user_course_constaint() -> bool:
301298
'usercourse', ('user_id', 'course_id'), True,
302299
),
303300
)
304-
except OperationalError as e:
305-
if 'already exists' in str(e):
306-
log.info(f'index usercourse already exists: {e}')
307-
else:
308-
raise
301+
except (OperationalError, ProgrammingError) as e:
302+
log.info(f'Index usercourse user and course already exists: {e}')
309303
db_config.database.commit()
310304

311305

0 commit comments

Comments
 (0)