|
| 1 | +"""Initial migration |
| 2 | +
|
| 3 | +Revision ID: 99bea044b892 |
| 4 | +Revises: |
| 5 | +Create Date: 2025-09-30 16:01:43.486314 |
| 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 = '99bea044b892' |
| 16 | +down_revision: Union[str, None] = None |
| 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 | + """Upgrade schema.""" |
| 23 | + # ### commands auto generated by Alembic - please adjust! ### |
| 24 | + op.create_table('otp', |
| 25 | + sa.Column('email', sa.String(), nullable=False), |
| 26 | + sa.Column('otp', sa.String(), nullable=False), |
| 27 | + sa.Column('expires_at', sa.DateTime(), nullable=False), |
| 28 | + sa.PrimaryKeyConstraint('email') |
| 29 | + ) |
| 30 | + op.create_index(op.f('ix_otp_email'), 'otp', ['email'], unique=False) |
| 31 | + op.create_table('tracks', |
| 32 | + sa.Column('id', sa.Integer(), nullable=False), |
| 33 | + sa.Column('title', sa.String(), nullable=False), |
| 34 | + sa.Column('description', sa.Text(), nullable=True), |
| 35 | + sa.PrimaryKeyConstraint('id'), |
| 36 | + sa.UniqueConstraint('title') |
| 37 | + ) |
| 38 | + op.create_index(op.f('ix_tracks_id'), 'tracks', ['id'], unique=False) |
| 39 | + op.create_table('users', |
| 40 | + sa.Column('id', sa.Integer(), nullable=False), |
| 41 | + sa.Column('email', sa.String(), nullable=False), |
| 42 | + sa.Column('name', sa.String(), nullable=False), |
| 43 | + sa.Column('role', sa.String(), nullable=False), |
| 44 | + sa.PrimaryKeyConstraint('id') |
| 45 | + ) |
| 46 | + op.create_index(op.f('ix_users_email'), 'users', ['email'], unique=True) |
| 47 | + op.create_index(op.f('ix_users_id'), 'users', ['id'], unique=False) |
| 48 | + op.create_table('leaderboard', |
| 49 | + sa.Column('id', sa.Integer(), nullable=False), |
| 50 | + sa.Column('track_id', sa.Integer(), nullable=True), |
| 51 | + sa.Column('mentee_id', sa.Integer(), nullable=True), |
| 52 | + sa.Column('total_points', sa.Integer(), nullable=True), |
| 53 | + sa.Column('tasks_completed', sa.Integer(), nullable=True), |
| 54 | + sa.ForeignKeyConstraint(['mentee_id'], ['users.id'], ), |
| 55 | + sa.ForeignKeyConstraint(['track_id'], ['tracks.id'], ), |
| 56 | + sa.PrimaryKeyConstraint('id') |
| 57 | + ) |
| 58 | + op.create_index(op.f('ix_leaderboard_id'), 'leaderboard', ['id'], unique=False) |
| 59 | + op.create_table('mentor_mentee_map', |
| 60 | + sa.Column('id', sa.Integer(), nullable=False), |
| 61 | + sa.Column('mentor_id', sa.Integer(), nullable=False), |
| 62 | + sa.Column('mentee_id', sa.Integer(), nullable=False), |
| 63 | + sa.ForeignKeyConstraint(['mentee_id'], ['users.id'], ), |
| 64 | + sa.ForeignKeyConstraint(['mentor_id'], ['users.id'], ), |
| 65 | + sa.PrimaryKeyConstraint('id'), |
| 66 | + sa.UniqueConstraint('mentor_id', 'mentee_id', name='unique_mentor_mentee') |
| 67 | + ) |
| 68 | + op.create_index(op.f('ix_mentor_mentee_map_id'), 'mentor_mentee_map', ['id'], unique=False) |
| 69 | + op.create_table('tasks', |
| 70 | + sa.Column('id', sa.Integer(), nullable=False), |
| 71 | + sa.Column('track_id', sa.Integer(), nullable=False), |
| 72 | + sa.Column('task_no', sa.Integer(), nullable=False), |
| 73 | + sa.Column('title', sa.String(), nullable=False), |
| 74 | + sa.Column('description', sa.Text(), nullable=True), |
| 75 | + sa.Column('points', sa.Integer(), nullable=True), |
| 76 | + sa.Column('deadline_days', sa.Integer(), nullable=True), |
| 77 | + sa.ForeignKeyConstraint(['track_id'], ['tracks.id'], ), |
| 78 | + sa.PrimaryKeyConstraint('id'), |
| 79 | + sa.UniqueConstraint('track_id', 'task_no', name='unique_track_task') |
| 80 | + ) |
| 81 | + op.create_index(op.f('ix_tasks_id'), 'tasks', ['id'], unique=False) |
| 82 | + op.create_table('submissions', |
| 83 | + sa.Column('id', sa.Integer(), nullable=False), |
| 84 | + sa.Column('mentee_id', sa.Integer(), nullable=False), |
| 85 | + sa.Column('task_id', sa.Integer(), nullable=False), |
| 86 | + sa.Column('reference_link', sa.Text(), nullable=False), |
| 87 | + sa.Column('status', sa.String(), nullable=True), |
| 88 | + sa.Column('submitted_at', sa.DateTime(), nullable=True), |
| 89 | + sa.Column('approved_at', sa.DateTime(), nullable=True), |
| 90 | + sa.Column('mentor_feedback', sa.Text(), nullable=True), |
| 91 | + sa.ForeignKeyConstraint(['mentee_id'], ['users.id'], ), |
| 92 | + sa.ForeignKeyConstraint(['task_id'], ['tasks.id'], ), |
| 93 | + sa.PrimaryKeyConstraint('id') |
| 94 | + ) |
| 95 | + op.create_index(op.f('ix_submissions_id'), 'submissions', ['id'], unique=False) |
| 96 | + # ### end Alembic commands ### |
| 97 | + |
| 98 | + |
| 99 | +def downgrade() -> None: |
| 100 | + """Downgrade schema.""" |
| 101 | + # ### commands auto generated by Alembic - please adjust! ### |
| 102 | + op.drop_index(op.f('ix_submissions_id'), table_name='submissions') |
| 103 | + op.drop_table('submissions') |
| 104 | + op.drop_index(op.f('ix_tasks_id'), table_name='tasks') |
| 105 | + op.drop_table('tasks') |
| 106 | + op.drop_index(op.f('ix_mentor_mentee_map_id'), table_name='mentor_mentee_map') |
| 107 | + op.drop_table('mentor_mentee_map') |
| 108 | + op.drop_index(op.f('ix_leaderboard_id'), table_name='leaderboard') |
| 109 | + op.drop_table('leaderboard') |
| 110 | + op.drop_index(op.f('ix_users_id'), table_name='users') |
| 111 | + op.drop_index(op.f('ix_users_email'), table_name='users') |
| 112 | + op.drop_table('users') |
| 113 | + op.drop_index(op.f('ix_tracks_id'), table_name='tracks') |
| 114 | + op.drop_table('tracks') |
| 115 | + op.drop_index(op.f('ix_otp_email'), table_name='otp') |
| 116 | + op.drop_table('otp') |
| 117 | + # ### end Alembic commands ### |
0 commit comments