Skip to content

Commit 108cd5b

Browse files
committed
feat: completed alembic db migration for events table
1 parent e03cede commit 108cd5b

3 files changed

Lines changed: 44 additions & 1 deletion

File tree

src/alembic/env.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import nominees.tables
1313
import officers.tables
1414
import candidates.tables
15+
import event.tables
1516
from alembic import context
1617

1718
# this is the Alembic Config object, which provides
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""created events_info table
2+
3+
Revision ID: 0990cd930610
4+
Revises: 0a2c458d1ddd
5+
Create Date: 2026-05-09 23:53:01.667539
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = '0990cd930610'
16+
down_revision: Union[str, None] = '0a2c458d1ddd'
17+
branch_labels: Union[str, Sequence[str], None] = None
18+
depends_on: Union[str, Sequence[str], None] = None
19+
20+
21+
def upgrade() -> None:
22+
# ### commands auto generated by Alembic - please adjust! ###
23+
op.create_table('event_info',
24+
sa.Column('eid', sa.Integer(), autoincrement=True, nullable=False),
25+
sa.Column('description', sa.Text(), nullable=True),
26+
sa.Column('name', sa.String(length=64), nullable=False),
27+
sa.Column('start_time', sa.DateTime(timezone=True), nullable=False),
28+
sa.Column('end_time', sa.DateTime(timezone=True), nullable=False),
29+
sa.Column('repeat', sa.String(length=64), nullable=False),
30+
sa.Column('start_date', sa.Date(), nullable=True),
31+
sa.Column('end_date', sa.Date(), nullable=True),
32+
sa.PrimaryKeyConstraint('eid', name=op.f('pk_event_info'))
33+
)
34+
# ### end Alembic commands ###
35+
36+
37+
def downgrade() -> None:
38+
# ### commands auto generated by Alembic - please adjust! ###
39+
op.drop_table('event_info')
40+
# ### end Alembic commands ###

src/event/tables.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from sqlalchemy import (
2+
Integer,
23
String,
34
DateTime,
45
Text,
@@ -14,7 +15,8 @@ class EventDB(Base):
1415

1516
eid: Mapped[int] = mapped_column(
1617
Integer,
17-
primary_key=True
18+
primary_key=True,
19+
autoincrement=True
1820
)
1921
description: Mapped[str] = mapped_column(
2022
Text,

0 commit comments

Comments
 (0)