add indexes for person models

This commit is contained in:
dominik24c 2022-05-19 18:11:41 +02:00
parent 40e65c518c
commit 22bd08c312
2 changed files with 36 additions and 2 deletions

View File

@ -10,6 +10,6 @@ class Base(db.Model):
class Person(db.Model): class Person(db.Model):
__abstract__ = True __abstract__ = True
first_name = db.Column(db.String(255), nullable=False) first_name = db.Column(db.String(255), index=True, nullable=False)
last_name = db.Column(db.String(255), nullable=False) last_name = db.Column(db.String(255), index=True, nullable=False)
email = db.Column(db.String(120), unique=True) email = db.Column(db.String(120), unique=True)

View File

@ -0,0 +1,34 @@
"""empty message
Revision ID: 84d4066483b8
Revises: 45be50e56689
Create Date: 2022-05-19 17:14:00.684001
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '84d4066483b8'
down_revision = '45be50e56689'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_index(op.f('ix_project_supervisors_first_name'), 'project_supervisors', ['first_name'], unique=False)
op.create_index(op.f('ix_project_supervisors_last_name'), 'project_supervisors', ['last_name'], unique=False)
op.create_index(op.f('ix_students_first_name'), 'students', ['first_name'], unique=False)
op.create_index(op.f('ix_students_last_name'), 'students', ['last_name'], unique=False)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_index(op.f('ix_students_last_name'), table_name='students')
op.drop_index(op.f('ix_students_first_name'), table_name='students')
op.drop_index(op.f('ix_project_supervisors_last_name'), table_name='project_supervisors')
op.drop_index(op.f('ix_project_supervisors_first_name'), table_name='project_supervisors')
# ### end Alembic commands ###