Spaces:
Build error
Build error
File size: 13,905 Bytes
b7a7f32 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
"""migrations
Revision ID: c6c1acf911ad
Revises:
Create Date: 2023-07-29 04:34:07.378969
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'c6c1acf911ad'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('school',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=128), nullable=False),
sa.Column('address', sa.String(length=64), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_table('userpermission',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_userpermission_name'), 'userpermission', ['name'], unique=True)
op.create_table('department',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=128), nullable=True),
sa.Column('school_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['school_id'], ['school.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('course',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('course_code', sa.String(), nullable=True),
sa.Column('course_name', sa.String(length=128), nullable=False),
sa.Column('course_credit', sa.SmallInteger(), nullable=True),
sa.Column('department_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['department_id'], ['department.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_course_course_code'), 'course', ['course_code'], unique=True)
op.create_table('program',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(length=64), nullable=True),
sa.Column('department_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['department_id'], ['department.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('assignment',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('due_date', sa.DateTime(), nullable=True),
sa.Column('marks', sa.Integer(), nullable=True),
sa.Column('title', sa.String(length=2048), nullable=True),
sa.Column('contents', sa.String(length=32168), nullable=True),
sa.Column('files', sa.ARRAY(sa.JSON()), nullable=True),
sa.Column('course_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['course_id'], ['course.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('group',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('program_id', sa.Integer(), nullable=True),
sa.Column('sem', sa.SmallInteger(), nullable=True),
sa.ForeignKeyConstraint(['program_id'], ['program.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('quiz',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('end_time', sa.DateTime(), nullable=True),
sa.Column('start_time', sa.DateTime(), nullable=True),
sa.Column('title', sa.String(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.Column('is_randomized', sa.Boolean(), nullable=True),
sa.Column('display_individual', sa.Boolean(), nullable=True),
sa.Column('total_marks', sa.Integer(), nullable=True),
sa.Column('course_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['course_id'], ['course.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('assignment_group_association',
sa.Column('group_id', sa.Integer(), nullable=True),
sa.Column('assignment_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['assignment_id'], ['assignment.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['group_id'], ['group.id'], ondelete='CASCADE')
)
op.create_table('class_session',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('start_time', sa.DateTime(), nullable=True),
sa.Column('end_time', sa.DateTime(), nullable=True),
sa.Column('course_id', sa.Integer(), nullable=True),
sa.Column('group_id', sa.Integer(), nullable=True),
sa.Column('description', sa.String(), nullable=True),
sa.ForeignKeyConstraint(['course_id'], ['course.id'], ondelete='cascade'),
sa.ForeignKeyConstraint(['group_id'], ['group.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('group_course_association',
sa.Column('course_id', sa.Integer(), nullable=True),
sa.Column('group_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['course_id'], ['course.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['group_id'], ['group.id'], ondelete='CASCADE')
)
op.create_table('group_quiz_association',
sa.Column('group_id', sa.Integer(), nullable=True),
sa.Column('quiz_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['group_id'], ['group.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['quiz_id'], ['quiz.id'], ondelete='CASCADE')
)
op.create_table('quiz_question',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('question_text', sa.String(), nullable=True),
sa.Column('question_image', sa.ARRAY(sa.String()), nullable=True),
sa.Column('options', sa.JSON(), nullable=False),
sa.Column('marks', sa.Integer(), nullable=True),
sa.Column('answer', sa.ARRAY(sa.Integer()), nullable=True),
sa.Column('quiz_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['quiz_id'], ['quiz.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('profile_image', sa.String(length=100), nullable=True),
sa.Column('full_name', sa.String(), nullable=True),
sa.Column('email', sa.String(), nullable=False),
sa.Column('two_fa_secret', sa.String(), nullable=True),
sa.Column('roll', sa.SmallInteger(), nullable=True),
sa.Column('group_id', sa.Integer(), nullable=True),
sa.Column('teacher_department_id', sa.Integer(), nullable=True),
sa.Column('dob', sa.Date(), nullable=False),
sa.Column('address', sa.String(length=128), nullable=False),
sa.Column('contact_number', sa.String(length=32), nullable=False),
sa.Column('hashed_password', sa.String(), nullable=False),
sa.Column('is_active', sa.Boolean(), nullable=True),
sa.Column('user_type', sa.SmallInteger(), nullable=False),
sa.Column('join_year', sa.SmallInteger(), nullable=True),
sa.ForeignKeyConstraint(['group_id'], ['group.id'], ondelete='cascade'),
sa.ForeignKeyConstraint(['teacher_department_id'], ['department.id'], ondelete='SET NULL'),
sa.PrimaryKeyConstraint('id')
)
op.create_index(op.f('ix_user_contact_number'), 'user', ['contact_number'], unique=False)
op.create_index(op.f('ix_user_email'), 'user', ['email'], unique=True)
op.create_index(op.f('ix_user_full_name'), 'user', ['full_name'], unique=False)
op.create_index(op.f('ix_user_id'), 'user', ['id'], unique=False)
op.create_index(op.f('ix_user_user_type'), 'user', ['user_type'], unique=False)
op.create_table('assignment_instructor_association',
sa.Column('instructor_id', sa.Integer(), nullable=True),
sa.Column('assignment_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['assignment_id'], ['assignment.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['instructor_id'], ['user.id'], ondelete='CASCADE')
)
op.create_table('assignment_upload',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('submission_date', sa.DateTime(), nullable=True),
sa.Column('marks_obtained', sa.Integer(), nullable=True),
sa.Column('files', sa.ARRAY(sa.JSON()), nullable=True),
sa.Column('assignment_id', sa.Integer(), nullable=True),
sa.Column('student_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['assignment_id'], ['assignment.id'], ondelete='cascade'),
sa.ForeignKeyConstraint(['student_id'], ['user.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('assignment_id', 'student_id', name='__student_assignment_uc')
)
op.create_table('attendant_class_session_association',
sa.Column('class_session_id', sa.Integer(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['class_session_id'], ['class_session.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE')
)
op.create_table('file',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('path', sa.String(), nullable=True),
sa.Column('file_type', sa.String(), nullable=True),
sa.Column('uploaded_datetime', sa.DateTime(), nullable=True),
sa.Column('class_session_id', sa.Integer(), nullable=False),
sa.Column('description', sa.String(), nullable=True),
sa.ForeignKeyConstraint(['class_session_id'], ['class_session.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('instructor_quiz_association',
sa.Column('instructor_id', sa.Integer(), nullable=True),
sa.Column('quiz_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['instructor_id'], ['user.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['quiz_id'], ['quiz.id'], ondelete='CASCADE')
)
op.create_table('personalnote',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('last_updated_time', sa.DateTime(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('tags', sa.ARRAY(sa.String(length=32)), nullable=True),
sa.Column('title', sa.String(length=128), nullable=True),
sa.Column('content', sa.String(length=32768), nullable=True),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('quiz_answer',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('marks_obtained', sa.Integer(), nullable=True),
sa.Column('options_selected', sa.JSON(), nullable=True),
sa.Column('quiz_id', sa.Integer(), nullable=True),
sa.Column('student_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['quiz_id'], ['quiz.id'], ondelete='cascade'),
sa.ForeignKeyConstraint(['student_id'], ['user.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('quiz_id', 'student_id', name='__student_quiz_uc')
)
op.create_table('teacher_group_course_association',
sa.Column('teacher_id', sa.Integer(), nullable=False),
sa.Column('group_id', sa.Integer(), nullable=False),
sa.Column('course_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['course_id'], ['course.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['group_id'], ['group.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['teacher_id'], ['user.id'], ondelete='CASCADE'),
sa.PrimaryKeyConstraint('teacher_id', 'group_id')
)
op.create_table('teachernote',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.Column('student_id', sa.Integer(), nullable=True),
sa.Column('message', sa.String(length=512), nullable=True),
sa.ForeignKeyConstraint(['student_id'], ['user.id'], ondelete='cascade'),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='cascade'),
sa.PrimaryKeyConstraint('id')
)
op.create_table('user_class_session_association',
sa.Column('class_session_id', sa.Integer(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['class_session_id'], ['class_session.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE')
)
op.create_table('user_permission_association',
sa.Column('permission_id', sa.Integer(), nullable=True),
sa.Column('user_id', sa.Integer(), nullable=True),
sa.ForeignKeyConstraint(['permission_id'], ['userpermission.id'], ondelete='CASCADE'),
sa.ForeignKeyConstraint(['user_id'], ['user.id'], ondelete='CASCADE')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('user_permission_association')
op.drop_table('user_class_session_association')
op.drop_table('teachernote')
op.drop_table('teacher_group_course_association')
op.drop_table('quiz_answer')
op.drop_table('personalnote')
op.drop_table('instructor_quiz_association')
op.drop_table('file')
op.drop_table('attendant_class_session_association')
op.drop_table('assignment_upload')
op.drop_table('assignment_instructor_association')
op.drop_index(op.f('ix_user_user_type'), table_name='user')
op.drop_index(op.f('ix_user_id'), table_name='user')
op.drop_index(op.f('ix_user_full_name'), table_name='user')
op.drop_index(op.f('ix_user_email'), table_name='user')
op.drop_index(op.f('ix_user_contact_number'), table_name='user')
op.drop_table('user')
op.drop_table('quiz_question')
op.drop_table('group_quiz_association')
op.drop_table('group_course_association')
op.drop_table('class_session')
op.drop_table('assignment_group_association')
op.drop_table('quiz')
op.drop_table('group')
op.drop_table('assignment')
op.drop_table('program')
op.drop_index(op.f('ix_course_course_code'), table_name='course')
op.drop_table('course')
op.drop_table('department')
op.drop_index(op.f('ix_userpermission_name'), table_name='userpermission')
op.drop_table('userpermission')
op.drop_table('school')
# ### end Alembic commands ###
|