Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schema check on startup #168

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

cbrinson-rise8
Copy link
Collaborator

@cbrinson-rise8 cbrinson-rise8 commented Jan 8, 2025

Description

On application startup, verify that database tables match the ORM.

Related Issues

closes #143

Additional Notes

Acceptance Criteria

  • A new function that verifies the tables called from the create_sessionmaker function
  • Tests to show that it works (may need to programmatically alter the tables in the test cases to show this)

Details / Tasks

On application startup, the database tables are optionally created. That is, they are only created if they don't exist. It's possible thought that the columns don't align to the ORM state. Enhance the startup procedure to verify that the database columns, name and type, match those specified of the ORM, if there is a mismatch raise a SQLAlchemyError with mismatch details.

Background / Context

Take a look at sqlalchemy.inspect for getting table information.

<--------------------- REMOVE THE LINES BELOW BEFORE MERGING --------------------->

Checklist

Please review and complete the following checklist before submitting your pull request:

  • I have ensured that the pull request is of a manageable size, allowing it to be reviewed within a single session.
  • I have reviewed my changes to ensure they are clear, concise, and well-documented.
  • I have updated the documentation, if applicable.
  • I have added or updated test cases to cover my changes, if applicable.
  • I have minimized the number of reviewers to include only those essential for the review.

Checklist for Reviewers

Please review and complete the following checklist during the review process:

  • The code follows best practices and conventions.
  • The changes implement the desired functionality or fix the reported issue.
  • The tests cover the new changes and pass successfully.
  • Any potential edge cases or error scenarios have been considered.

@cbrinson-rise8 cbrinson-rise8 self-assigned this Jan 8, 2025
@cbrinson-rise8 cbrinson-rise8 added the feature New feature or request label Jan 8, 2025
@cbrinson-rise8 cbrinson-rise8 force-pushed the feat/schema-check-on-startup branch 2 times, most recently from c76979d to 535a3d4 Compare January 8, 2025 18:33
@cbrinson-rise8 cbrinson-rise8 force-pushed the feat/schema-check-on-startup branch from 2517424 to 322400a Compare January 9, 2025 18:19
Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 96.29630% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.19%. Comparing base (b1cdc7d) to head (322400a).

Files with missing lines Patch % Lines
src/recordlinker/database/__init__.py 96.29% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #168      +/-   ##
==========================================
- Coverage   97.21%   97.19%   -0.03%     
==========================================
  Files          30       30              
  Lines        1328     1354      +26     
==========================================
+ Hits         1291     1316      +25     
- Misses         37       38       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cbrinson-rise8 cbrinson-rise8 marked this pull request as ready for review January 10, 2025 20:04
@ericbuckley
Copy link
Collaborator

@cbrinson-rise8 it looks like the smoke tests are failing, does the new verify function work in the docker compose environment? I'm wondering if we need to somehow check this with all 4 databases?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

schema check on startup
2 participants