diff --git a/acmsite/models.py b/acmsite/models.py index e9490bf..a66b15c 100644 --- a/acmsite/models.py +++ b/acmsite/models.py @@ -1,6 +1,6 @@ from flask import flash, redirect, url_for from flask_login import UserMixin -from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String, null +from sqlalchemy import Boolean, Column, Date, DateTime, ForeignKey, Integer, String, null import csv from . import db from . import login @@ -35,6 +35,14 @@ def unauth(): flash("Please log in first!") return redirect("/") +class Officer(db.Model): + __tablename__ = "acm_officers" + id = Column(String, primary_key=True) + user_id = Column(String, ForeignKey('acm_users.id'), nullable=False) + term_start = Column(Date, nullable=False) + term_end = Column(Date, nullable=True) + position = Column(String, nullable=False) + class PwResetRequest(db.Model): id = Column(String, primary_key=True) user_id = Column(String, ForeignKey('acm_users.id'), nullable=False) diff --git a/migrations/versions/4fa893cdd432_create_officers_table.py b/migrations/versions/4fa893cdd432_create_officers_table.py new file mode 100644 index 0000000..5c517a5 --- /dev/null +++ b/migrations/versions/4fa893cdd432_create_officers_table.py @@ -0,0 +1,36 @@ +"""Create officers table + +Revision ID: 4fa893cdd432 +Revises: 69cccb10f676 +Create Date: 2024-03-22 13:54:39.037307 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '4fa893cdd432' +down_revision = '69cccb10f676' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.create_table('acm_officers', + sa.Column('id', sa.String(), nullable=False), + sa.Column('user_id', sa.String(), nullable=False), + sa.Column('term_start', sa.Date(), nullable=False), + sa.Column('term_end', sa.Date(), nullable=True), + sa.Column('position', sa.String(), nullable=False), + sa.ForeignKeyConstraint(['user_id'], ['acm_users.id'], ), + sa.PrimaryKeyConstraint('id') + ) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_table('acm_officers') + # ### end Alembic commands ###