-
Notifications
You must be signed in to change notification settings - Fork 32
🎨 database+web-server: Extending user pre-registration workflow and asyncpg upgrades 🗃️ #7709
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
Merged
pcrespov
merged 13 commits into
ITISFoundation:master
from
pcrespov:is69/pre-registration-table
May 21, 2025
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ede2972
✨ Add AccountRequestStatus enum to manage account request states
pcrespov 74be609
🐛 Fix pk_value handling in insert_and_get_row functions for better co…
pcrespov 6f32644
✨ Add pre-registration columns and update user linking logic for acco…
pcrespov 914a90b
🐛 Refactor user fixture to use asyncpg and improve database connectio…
pcrespov d31185a
🐛 Refactor database connection handling in authentication and change …
pcrespov 95b8462
drafting tests for users repository
pcrespov 865ebcf
moved functions
pcrespov 2c1b615
🐛 Fix return value in create_user_pre_registration and remove unused …
pcrespov 93e7112
fixing tests
pcrespov b228936
fix pylint
pcrespov 7993efb
fixes datetimte in db
pcrespov 2c1c5b4
Merge branch 'master' into is69/pre-registration-table
pcrespov 7b56d82
Merge branch 'master' into is69/pre-registration-table
pcrespov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
140 changes: 140 additions & 0 deletions
140
...simcore_postgres_database/migration/versions/ba9c4816a31b_new_pre_registration_columns.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| """new pre-registration columns | ||
|
|
||
| Revision ID: ba9c4816a31b | ||
| Revises: b39f2dc87ccd | ||
| Create Date: 2025-05-19 15:21:40.182354+00:00 | ||
|
|
||
| """ | ||
|
|
||
| import sqlalchemy as sa | ||
| from alembic import op | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision = "ba9c4816a31b" | ||
| down_revision = "b39f2dc87ccd" | ||
| branch_labels = None | ||
| depends_on = None | ||
|
|
||
|
|
||
| def upgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| # Create the enum type first before using it | ||
| account_request_status = sa.Enum( | ||
| "PENDING", "APPROVED", "REJECTED", name="accountrequeststatus" | ||
| ) | ||
| account_request_status.create(op.get_bind(), checkfirst=True) | ||
|
|
||
| op.add_column( | ||
| "users_pre_registration_details", | ||
| sa.Column( | ||
| "id", | ||
| sa.BigInteger(), | ||
| sa.Identity(always=False, start=1, cycle=False), | ||
| nullable=False, | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "users_pre_registration_details", | ||
| sa.Column( | ||
| "account_request_status", | ||
| account_request_status, # Use the created enum type | ||
| server_default="PENDING", # Simply use the string value as default | ||
| nullable=False, | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "users_pre_registration_details", | ||
| sa.Column( | ||
| "account_request_reviewed_by", | ||
| sa.Integer(), | ||
| nullable=True, | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "users_pre_registration_details", | ||
| sa.Column( | ||
| "account_request_reviewed_at", | ||
| sa.DateTime(timezone=True), | ||
| nullable=True, | ||
| ), | ||
| ) | ||
| op.add_column( | ||
| "users_pre_registration_details", | ||
| sa.Column("product_name", sa.String(), nullable=True), | ||
| ) | ||
| op.drop_constraint( | ||
| "users_pre_registration_details_pre_email_key", | ||
| "users_pre_registration_details", | ||
| type_="unique", | ||
| ) | ||
| op.create_foreign_key( | ||
| "fk_users_pre_registration_details_product_name", | ||
| "users_pre_registration_details", | ||
| "products", | ||
| ["product_name"], | ||
| ["name"], | ||
| onupdate="CASCADE", | ||
| ondelete="SET NULL", | ||
| ) | ||
| # Add foreign key for account_request_reviewed_by | ||
| op.create_foreign_key( | ||
| "fk_users_pre_registration_reviewed_by_user_id", | ||
| "users_pre_registration_details", | ||
| "users", | ||
| ["account_request_reviewed_by"], | ||
| ["id"], | ||
| onupdate="CASCADE", | ||
| ondelete="SET NULL", | ||
| ) | ||
| # Set primary key on id column | ||
| op.create_primary_key( | ||
| "users_pre_registration_details_pk", | ||
| "users_pre_registration_details", | ||
| ["id"], | ||
| ) | ||
| # Add composite unique constraint on pre_email and product_name | ||
| op.create_unique_constraint( | ||
| "users_pre_registration_details_pre_email_product_name_key", | ||
| "users_pre_registration_details", | ||
| ["pre_email", "product_name"], | ||
| ) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade(): | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| # Drop the composite unique constraint | ||
| op.drop_constraint( | ||
| "users_pre_registration_details_pre_email_product_name_key", | ||
| "users_pre_registration_details", | ||
| type_="unique", | ||
| ) | ||
| op.drop_constraint( | ||
| "users_pre_registration_details_pk", | ||
| "users_pre_registration_details", | ||
| type_="primary", | ||
| ) | ||
| op.drop_constraint( | ||
| "fk_users_pre_registration_reviewed_by_user_id", | ||
| "users_pre_registration_details", | ||
| type_="foreignkey", | ||
| ) | ||
| op.drop_constraint( | ||
| "fk_users_pre_registration_details_product_name", | ||
| "users_pre_registration_details", | ||
| type_="foreignkey", | ||
| ) | ||
| op.create_unique_constraint( | ||
| "users_pre_registration_details_pre_email_key", | ||
| "users_pre_registration_details", | ||
| ["pre_email"], | ||
| ) | ||
| op.drop_column("users_pre_registration_details", "product_name") | ||
| op.drop_column("users_pre_registration_details", "account_request_reviewed_at") | ||
| op.drop_column("users_pre_registration_details", "account_request_reviewed_by") | ||
| op.drop_column("users_pre_registration_details", "account_request_status") | ||
| op.drop_column("users_pre_registration_details", "id") | ||
|
|
||
| # Drop the enum type in downgrade | ||
| sa.Enum(name="accountrequeststatus").drop(op.get_bind(), checkfirst=True) | ||
| # ### end Alembic commands ### |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.