-
Notifications
You must be signed in to change notification settings - Fork 1
✨ Add applications and project members functionality with schema updates #68
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
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d40622f
✨ Add applications and project members functionality with schema updates
andiazdi ace60df
:bug: fix tests
andiazdi 3d4bb75
✨ Update project model and data access layer to allow nullable fields…
andiazdi c1af600
✨ Refactor project exception handling by moving ProjectNotFoundError …
andiazdi 903a14f
✨ Rename ProjectNotFoundError to ApplicationNotFoundError
andiazdi 8672ab2
✨ Change date fields to datetime format in applications, project memb…
andiazdi db07f61
✨ Update import to use ApplicationNotFoundError in data_access.py
andiazdi 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
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
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
97 changes: 97 additions & 0 deletions
97
backend/app/migrations/versions/6e2af57b2c75_change_date_to_datetime_format.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,97 @@ | ||
| """change date to datetime format | ||
|
|
||
| Revision ID: 6e2af57b2c75 | ||
| Revises: 843428e10d39 | ||
| Create Date: 2025-07-09 16:56:58.620295 | ||
|
|
||
| """ | ||
|
|
||
| from typing import Sequence, Union | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
|
|
||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = "6e2af57b2c75" | ||
| down_revision: Union[str, Sequence[str], None] = "843428e10d39" | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| """Upgrade schema.""" | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.alter_column( | ||
| "applications", | ||
| "created_at", | ||
| existing_type=sa.DATE(), | ||
| type_=sa.DateTime(), | ||
| existing_nullable=True, | ||
| ) | ||
| op.alter_column( | ||
| "project_members", | ||
| "created_at", | ||
| existing_type=sa.DATE(), | ||
| type_=sa.DateTime(), | ||
| existing_nullable=True, | ||
| ) | ||
| op.alter_column( | ||
| "projects", | ||
| "created_at", | ||
| existing_type=sa.DATE(), | ||
| type_=sa.DateTime(), | ||
| existing_nullable=True, | ||
| ) | ||
| op.alter_column( | ||
| "projects", "is_public", existing_type=sa.BOOLEAN(), nullable=True | ||
| ) | ||
| op.alter_column( | ||
| "projects", "ceo_id", existing_type=sa.INTEGER(), nullable=True | ||
| ) | ||
| op.alter_column( | ||
| "projects", "is_opensource", existing_type=sa.BOOLEAN(), nullable=True | ||
| ) | ||
| op.alter_column( | ||
| "projects", "is_dead", existing_type=sa.BOOLEAN(), nullable=True | ||
| ) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| """Downgrade schema.""" | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.alter_column( | ||
| "projects", "is_dead", existing_type=sa.BOOLEAN(), nullable=False | ||
| ) | ||
| op.alter_column( | ||
| "projects", "is_opensource", existing_type=sa.BOOLEAN(), nullable=False | ||
| ) | ||
| op.alter_column( | ||
| "projects", "ceo_id", existing_type=sa.INTEGER(), nullable=False | ||
| ) | ||
| op.alter_column( | ||
| "projects", "is_public", existing_type=sa.BOOLEAN(), nullable=False | ||
| ) | ||
| op.alter_column( | ||
| "projects", | ||
| "created_at", | ||
| existing_type=sa.DateTime(), | ||
| type_=sa.DATE(), | ||
| existing_nullable=True, | ||
| ) | ||
| op.alter_column( | ||
| "project_members", | ||
| "created_at", | ||
| existing_type=sa.DateTime(), | ||
| type_=sa.DATE(), | ||
| existing_nullable=True, | ||
| ) | ||
| op.alter_column( | ||
| "applications", | ||
| "created_at", | ||
| existing_type=sa.DateTime(), | ||
| type_=sa.DATE(), | ||
| existing_nullable=True, | ||
| ) | ||
| # ### end Alembic commands ### |
86 changes: 86 additions & 0 deletions
86
backend/app/migrations/versions/843428e10d39_add_applications_project_member_edit_.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,86 @@ | ||
| """add applications, project_member, edit projects | ||
|
|
||
| Revision ID: 843428e10d39 | ||
| Revises: 9486dd2901de | ||
| Create Date: 2025-07-09 13:50:32.127176 | ||
|
|
||
| """ | ||
|
|
||
| from typing import Sequence, Union | ||
|
|
||
| from alembic import op | ||
| import sqlalchemy as sa | ||
| from sqlalchemy.dialects import postgresql | ||
|
|
||
| # revision identifiers, used by Alembic. | ||
| revision: str = "843428e10d39" | ||
| down_revision: Union[str, Sequence[str], None] = "9486dd2901de" | ||
| branch_labels: Union[str, Sequence[str], None] = None | ||
| depends_on: Union[str, Sequence[str], None] = None | ||
|
|
||
|
|
||
| def upgrade() -> None: | ||
| """Upgrade schema.""" | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.create_table( | ||
| "applications", | ||
| sa.Column("project_id", sa.Integer(), nullable=False), | ||
| sa.Column("user_id", sa.Integer(), nullable=False), | ||
| sa.Column("created_at", sa.Date(), nullable=True), | ||
| sa.Column("is_approved", sa.Boolean(), nullable=True), | ||
| sa.ForeignKeyConstraint( | ||
| ["project_id"], | ||
| ["projects.id"], | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["user_id"], | ||
| ["users.id"], | ||
| ), | ||
| sa.PrimaryKeyConstraint("project_id", "user_id"), | ||
| ) | ||
| op.create_index( | ||
| "ix_applications_project_user", | ||
| "applications", | ||
| ["project_id", "user_id"], | ||
| unique=True, | ||
| ) | ||
| op.create_table( | ||
| "project_members", | ||
| sa.Column("project_id", sa.Integer(), nullable=False), | ||
| sa.Column("user_id", sa.Integer(), nullable=False), | ||
| sa.Column("created_at", sa.Date(), nullable=True), | ||
| sa.ForeignKeyConstraint( | ||
| ["project_id"], | ||
| ["projects.id"], | ||
| ), | ||
| sa.ForeignKeyConstraint( | ||
| ["user_id"], | ||
| ["users.id"], | ||
| ), | ||
| sa.PrimaryKeyConstraint("project_id", "user_id"), | ||
| ) | ||
| op.create_index( | ||
| "ix_project_members_project_id_user_id", | ||
| "project_members", | ||
| ["project_id", "user_id"], | ||
| unique=False, | ||
| ) | ||
| op.add_column("projects", sa.Column("ceo_id", sa.Integer(), nullable=True)) | ||
| op.add_column("projects", sa.Column("is_opensource", sa.Boolean(), nullable=True)) | ||
| op.add_column("projects", sa.Column("is_dead", sa.Boolean(), nullable=True)) | ||
| op.create_foreign_key(None, "projects", "users", ["ceo_id"], ["id"]) | ||
| # ### end Alembic commands ### | ||
|
|
||
|
|
||
| def downgrade() -> None: | ||
| """Downgrade schema.""" | ||
| # ### commands auto generated by Alembic - please adjust! ### | ||
| op.drop_constraint(None, "projects", type_="foreignkey") | ||
| op.drop_column("projects", "is_dead") | ||
| op.drop_column("projects", "is_opensource") | ||
| op.drop_column("projects", "ceo_id") | ||
| op.drop_index("ix_project_members_project_id_user_id", table_name="project_members") | ||
| op.drop_table("project_members") | ||
| op.drop_index("ix_applications_project_user", table_name="applications") | ||
| op.drop_table("applications") | ||
| # ### 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
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 |
|---|---|---|
| @@ -1,7 +1,11 @@ | ||
| from .projects import Project | ||
| from .users import User | ||
| from .project_member import ProjectMember | ||
| from .applications import Application | ||
|
|
||
| __all__ = [ | ||
| "Project", | ||
| "User", | ||
| "ProjectMember", | ||
| "Application", | ||
| ] |
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,25 @@ | ||
| from sqlalchemy import ( | ||
| Column, | ||
| Integer, | ||
| Index, | ||
| DateTime, | ||
| func, | ||
| Boolean, | ||
| ForeignKey, | ||
| PrimaryKeyConstraint, | ||
| ) | ||
| from dependencies.database import base | ||
|
|
||
|
|
||
| class Application(base): | ||
| __tablename__ = "applications" | ||
|
|
||
| project_id = Column(Integer, ForeignKey("projects.id")) | ||
| user_id = Column(Integer, ForeignKey("users.id")) | ||
| created_at = Column(DateTime, default=func.current_timestamp()) | ||
| is_approved = Column(Boolean, nullable=True) | ||
|
|
||
| __table_args__ = ( | ||
| Index("ix_applications_project_user", "project_id", "user_id", unique=True), | ||
| PrimaryKeyConstraint("project_id", "user_id"), | ||
| ) |
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,23 @@ | ||
| from sqlalchemy import ( | ||
| Column, | ||
| Integer, | ||
| Index, | ||
| DateTime, | ||
| func, | ||
| ForeignKey, | ||
| PrimaryKeyConstraint, | ||
| ) | ||
| from dependencies.database import base | ||
|
|
||
|
|
||
| class ProjectMember(base): | ||
| __tablename__ = "project_members" | ||
|
|
||
| project_id = Column(Integer, ForeignKey("projects.id"), nullable=False) | ||
| user_id = Column(Integer, ForeignKey("users.id"), nullable=False) | ||
| created_at = Column(DateTime, default=func.current_timestamp()) | ||
|
|
||
| __table_args__ = ( | ||
| PrimaryKeyConstraint("project_id", "user_id"), | ||
| Index("ix_project_members_project_id_user_id", "project_id", "user_id"), | ||
| ) |
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 |
|---|---|---|
| @@ -1,13 +1,19 @@ | ||
| from sqlalchemy import Column, Integer, String, Date, func, Boolean | ||
| from sqlalchemy import Column, Integer, String, DateTime, func, Boolean, ForeignKey | ||
| from dependencies.database import base | ||
|
|
||
|
|
||
| class Project(base): | ||
| __tablename__ = "projects" | ||
|
|
||
| id = Column(Integer, primary_key=True, index=True) | ||
| id = Column(Integer, primary_key=True, index=True, autoincrement=True) | ||
| title = Column(String, unique=True, nullable=False) | ||
| description = Column(String) | ||
| created_at = Column(Date, default=func.current_date()) | ||
| is_public = Column(Boolean, nullable=False) | ||
| created_at = Column(DateTime, default=func.current_timestamp()) | ||
| is_public = Column(Boolean, nullable=True, default=True) | ||
| status = Column(String) | ||
| ceo_id = Column(Integer, ForeignKey("users.id"), nullable=True) | ||
| is_opensource = Column(Boolean, nullable=True, default=True) | ||
| is_dead = Column(Boolean, nullable=True, default=False) | ||
|
|
||
| def __repr__(self): | ||
| return f"<Project({', '.join(f'{k}={getattr(self, k)!r}' for k in self.__table__.columns.keys())})>" |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Committing in the DB dependency will commit after all operations, including GET requests. Consider committing only in write operations or in service methods.