diff --git a/backend/alembic/versions/eb472f05f70e_recreate_tables.py b/backend/alembic/versions/eb472f05f70e_recreate_tables.py index 98cf2a2c..eee42a68 100644 --- a/backend/alembic/versions/eb472f05f70e_recreate_tables.py +++ b/backend/alembic/versions/eb472f05f70e_recreate_tables.py @@ -21,39 +21,42 @@ def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table('subject', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) op.create_table('website_user', - sa.Column('uid', sa.String(), nullable=False), - sa.Column('given_name', sa.String(), nullable=False), - sa.Column('mail', sa.String(), nullable=False), - sa.Column('is_admin', sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint('uid') - ) + sa.Column('uid', sa.String(), nullable=False), + sa.Column('given_name', sa.String(), nullable=False), + sa.Column('mail', sa.String(), nullable=False), + sa.Column('is_admin', sa.Boolean(), nullable=False), + sa.PrimaryKeyConstraint('uid') + ) op.create_table('project', - sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), - sa.Column('deadline', sa.Date(), nullable=False, check_constraint='deadline >= CURRENT_DATE'), - sa.Column('name', sa.String(), nullable=False), - sa.Column('subjectId', sa.String(), nullable=True), - sa.Column('description', sa.String(), nullable=True), - sa.ForeignKeyConstraint(['subjectId'], ['subject.id'], ondelete='SET NULL'), - sa.PrimaryKeyConstraint('id') - ) + sa.Column('id', sa.BigInteger(), + autoincrement=True, nullable=False), + sa.Column('deadline', sa.Date(), nullable=False, + check_constraint='deadline >= CURRENT_DATE'), + sa.Column('name', sa.String(), nullable=False), + sa.Column('subjectId', sa.String(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.ForeignKeyConstraint( + ['subjectId'], ['subject.id'], ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id') + ) op.create_index(op.f('ix_project_id'), 'project', ['id'], unique=False) op.create_table('student_subject', - sa.Column('uid', sa.String(), nullable=True), - sa.Column('subject_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['subject_id'], ['subject.id'], ), - sa.ForeignKeyConstraint(['uid'], ['website_user.uid'], ) - ) + sa.Column('uid', sa.String(), nullable=True), + sa.Column('subject_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['subject_id'], ['subject.id'], ), + sa.ForeignKeyConstraint(['uid'], ['website_user.uid'], ) + ) op.create_table('teacher_subject', - sa.Column('uid', sa.String(), nullable=True), - sa.Column('subject_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['subject_id'], ['subject.id'], ), - sa.ForeignKeyConstraint(['uid'], ['website_user.uid'], ) - ) + sa.Column('uid', sa.String(), nullable=True), + sa.Column('subject_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['subject_id'], ['subject.id'], ), + sa.ForeignKeyConstraint(['uid'], ['website_user.uid'], ) + ) # ### end Alembic commands ### diff --git a/backend/alembic/versions/fc317e930257_correct_project_subjectid_type.py b/backend/alembic/versions/fc317e930257_correct_project_subjectid_type.py index fbf2e9fe..367b0dee 100644 --- a/backend/alembic/versions/fc317e930257_correct_project_subjectid_type.py +++ b/backend/alembic/versions/fc317e930257_correct_project_subjectid_type.py @@ -21,39 +21,42 @@ def upgrade() -> None: # ### commands auto generated by Alembic - please adjust! ### op.create_table('subject', - sa.Column('id', sa.Integer(), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.PrimaryKeyConstraint('id') - ) + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('name', sa.String(), nullable=False), + sa.PrimaryKeyConstraint('id') + ) op.create_table('website_user', - sa.Column('uid', sa.String(), nullable=False), - sa.Column('given_name', sa.String(), nullable=False), - sa.Column('mail', sa.String(), nullable=False), - sa.Column('is_admin', sa.Boolean(), nullable=False), - sa.PrimaryKeyConstraint('uid') - ) + sa.Column('uid', sa.String(), nullable=False), + sa.Column('given_name', sa.String(), nullable=False), + sa.Column('mail', sa.String(), nullable=False), + sa.Column('is_admin', sa.Boolean(), nullable=False), + sa.PrimaryKeyConstraint('uid') + ) op.create_table('project', - sa.Column('id', sa.BigInteger(), autoincrement=True, nullable=False), - sa.Column('deadline', sa.Date(), nullable=False), - sa.Column('name', sa.String(), nullable=False), - sa.Column('subject_id', sa.BigInteger(), nullable=True), - sa.Column('description', sa.String(), nullable=True), - sa.CheckConstraint('deadline >= CURRENT_DATE', name='deadline_check'), - sa.ForeignKeyConstraint(['subject_id'], ['subject.id'], ondelete='SET NULL'), - sa.PrimaryKeyConstraint('id') - ) + sa.Column('id', sa.BigInteger(), + autoincrement=True, nullable=False), + sa.Column('deadline', sa.Date(), nullable=False), + sa.Column('name', sa.String(), nullable=False), + sa.Column('subject_id', sa.BigInteger(), nullable=True), + sa.Column('description', sa.String(), nullable=True), + sa.CheckConstraint('deadline >= CURRENT_DATE', + name='deadline_check'), + sa.ForeignKeyConstraint( + ['subject_id'], ['subject.id'], ondelete='SET NULL'), + sa.PrimaryKeyConstraint('id') + ) op.create_table('student_subject', - sa.Column('uid', sa.String(), nullable=True), - sa.Column('subject_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['subject_id'], ['subject.id'], ), - sa.ForeignKeyConstraint(['uid'], ['website_user.uid'], ) - ) + sa.Column('uid', sa.String(), nullable=True), + sa.Column('subject_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['subject_id'], ['subject.id'], ), + sa.ForeignKeyConstraint(['uid'], ['website_user.uid'], ) + ) op.create_table('teacher_subject', - sa.Column('uid', sa.String(), nullable=True), - sa.Column('subject_id', sa.Integer(), nullable=True), - sa.ForeignKeyConstraint(['subject_id'], ['subject.id'], ), - sa.ForeignKeyConstraint(['uid'], ['website_user.uid'], ) - ) + sa.Column('uid', sa.String(), nullable=True), + sa.Column('subject_id', sa.Integer(), nullable=True), + sa.ForeignKeyConstraint(['subject_id'], ['subject.id'], ), + sa.ForeignKeyConstraint(['uid'], ['website_user.uid'], ) + ) # ### end Alembic commands ### diff --git a/backend/src/main.py b/backend/src/main.py index 45972696..20b870fa 100644 --- a/backend/src/main.py +++ b/backend/src/main.py @@ -26,6 +26,7 @@ app.include_router(project_router) + @app.get("/api") async def root(): return {"message": "Hello World"} diff --git a/backend/src/project/models.py b/backend/src/project/models.py index f4a6d18a..ad4906a4 100644 --- a/backend/src/project/models.py +++ b/backend/src/project/models.py @@ -9,7 +9,8 @@ class Project(Base): id = Column(BigInteger, primary_key=True, autoincrement=True) deadline = Column(Date, nullable=False) name = Column(String, nullable=False) - subject_id = Column(BigInteger, ForeignKey('subject.id', ondelete="SET NULL"), nullable=True) # Adjusted to BigInteger + subject_id = Column(BigInteger, ForeignKey( + 'subject.id', ondelete="SET NULL"), nullable=True) # Adjusted to BigInteger description = Column(String, nullable=True) enroll_deadline = Column(Date, nullable=True)