Skip to content

Commit 52b1fda

Browse files
committed
Add Semester Enum to Co-Op Table
1 parent b20c083 commit 52b1fda

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

conditional/models/models.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,14 @@ class CurrentCoops(db.Model):
191191
__tablename__ = 'current_coops'
192192
id = Column(Integer, primary_key=True)
193193
uid = Column(String(32), nullable=False)
194-
active = Column(Boolean, nullable=False)
195194
date_created = Column(Date, nullable=False)
195+
semester = Column(Enum('Fall', 'Spring', name="co_op_enum"), nullable=False)
196196

197-
def __init__(self, uid):
197+
def __init__(self, uid, semester):
198198
self.uid = uid
199199
self.active = True
200200
self.date_created = datetime.now()
201+
self.semester = semester
201202

202203

203204
class OnFloorStatusAssigned(db.Model):

migrations/versions/2c3193839c9d_.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""Add Semester Enum to Co-Op Table
2+
3+
Revision ID: 2c3193839c9d
4+
Revises: 6ae578b76143
5+
Create Date: 2017-05-24 00:18:22.645256
6+
7+
"""
8+
9+
# revision identifiers, used by Alembic.
10+
revision = '2c3193839c9d'
11+
down_revision = '6ae578b76143'
12+
13+
from alembic import op
14+
import sqlalchemy as sa
15+
from sqlalchemy.dialects import postgresql
16+
17+
18+
def upgrade():
19+
### commands auto generated by Alembic - please adjust! ###
20+
semester = postgresql.ENUM('Fall', 'Spring', 'Neither', name='co_op_enum')
21+
semester.create(op.get_bind())
22+
op.add_column('current_coops', sa.Column('semester', sa.Enum('Fall', 'Spring', 'Neither', name='co_op_enum'), server_default='Neither', nullable=False))
23+
op.drop_column('current_coops', 'active')
24+
### end Alembic commands ###
25+
26+
27+
def downgrade():
28+
### commands auto generated by Alembic - please adjust! ###
29+
op.add_column('current_coops', sa.Column('active', sa.BOOLEAN(), server_default=sa.sql.expression.true(), autoincrement=False, nullable=False))
30+
op.drop_column('current_coops', 'semester')
31+
### end Alembic commands ###

0 commit comments

Comments
 (0)