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

Cleaned up branch to no longer be a full merge of #7 and #18 #20

Merged

Conversation

jcadam14
Copy link
Contributor

@jcadam14 jcadam14 commented Jan 9, 2024

Closes #13

Created a new branch that focuses purely on the alembic script needs instead of a full merge of #7 and #18 into the #13 branch. Makes it so only the code related to the migrations is needed for review. Originally I merged them all together to test starting the service in poetry to make sure the tables are created correctly in Postgres but that made the PR have a lot of files that were already covered in other PRs. Still the case with the entities/models directory but couldn't get around that.

Additions

  • Added db_revision folder using alembic init and updated files for SBL specifics (using user-fi as an example)
  • Added migration files using alembic revision for each submission table (submission, filing, filing_period)
  • Updated migration files for table specifics
  • Added pytest migrations tests for new tables, columns, and fks
  • Had to merge in the entities/models dir since the migrations use the enumerations

Removals

Changes

Testing

  1. Run pytest in poetry shell (or poetry run pytest) and verify the tests pass

Screenshots

Notes

Todos

Checklist

  • PR has an informative and human-readable title
  • Changes are limited to a single goal (no scope creep)
  • Code can be automatically merged (no conflicts)
  • Code follows the standards laid out in the development playbook
  • Passes all existing automated tests
  • Any change in functionality is tested
  • New functions are documented (with a description, list of inputs, and expected output)
  • Placeholder code is flagged / future todos are captured in comments
  • Visually tested in supported browsers and devices (see checklist below 👇)
  • Project documentation has been updated (including the "Unreleased" section of the CHANGELOG)
  • Reviewers requested with the Reviewers tool ➡️

Testing checklist

Browsers

  • Chrome
  • Firefox
  • Safari
  • Internet Explorer 8, 9, 10, and 11
  • Edge
  • iOS Safari
  • Chrome for Android

Accessibility

  • Keyboard friendly
  • Screen reader friendly

Other

  • Is useable without CSS
  • Is useable without JS
  • Flexible from small to large screens
  • No linting errors or warnings
  • JavaScript tests are passing

"filing",
sa.Column("id", sa.INTEGER, primary_key=True, autoincrement=True),
sa.Column("lei", sa.String, nullable=False),
sa.Column("state", sa.Enum(FilingState, name="filingstate")),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be possible to create the enum types as its own script instead of relying on the model? If I'm not mistaken, this will auto generate the type creation at this point in time correct? Future updates to the enum in code doesn't automatically get synced, then we run into sync issues, where future code may have additional values, and they get automatically generated, but there are revisions that add the new enums.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd like to keep this and the code models decoupled, and be explicit on what we're doing with the database.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup this makes sense. At the time I did it to ensure there were no copy/paste errors for the enum type, but yeah if we rollback this would continue to use whatever is in FilingState and not what should be in there for the rollback. So I'll create a new script to create the enums in the db that these are dependent on.



def upgrade() -> None:
if not table_exists("filing"):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's move away from this table_exists check now, since this is a brand new repo where all the tables are being created by alembic.

- Removed the if_table_exists util.py
- Updated table creations to not use the model enum py file, instead builds based on
  default values.  Can be updated later with enum_migration.update_value
@jcadam14 jcadam14 requested a review from lchen-2101 January 16, 2024 16:21
Comment on lines 25 to 27
sa.Column("start_period", sa.DateTime, server_default=sa.func.now(), nullable=False),
sa.Column("end_period", sa.DateTime, server_default=sa.func.now(), nullable=False),
sa.Column("due", sa.DateTime, server_default=sa.func.now(), nullable=False),
Copy link
Collaborator

@lchen-2101 lchen-2101 Jan 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these shouldn't have defaults, we want to explicitly specify them as we create them.
they would look something like:
start_period: 1/1/2024
end_period: 12/31/2024
due: 3/1/2025

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

otherwise looks good, ready to merge after this change.

@jcadam14 jcadam14 merged commit f1a7c74 into main Jan 17, 2024
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add initial alembic scripts for creating submission tables
2 participants