сделал сквош первых миграций

This commit is contained in:
Андрей Дувакин 2025-03-11 14:41:55 +05:00
parent ca9b519490
commit b4de82a6e9
15 changed files with 73 additions and 615 deletions

View File

@ -1,30 +0,0 @@
"""Убрал поле Количество у таблицы наборов
Revision ID: 0249759985c3
Revises: 27fa11120115
Create Date: 2025-02-20 10:59:11.341413
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '0249759985c3'
down_revision: Union[str, None] = '27fa11120115'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('sets', 'count')
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('sets', sa.Column('count', sa.INTEGER(), autoincrement=False, nullable=False))
# ### end Alembic commands ###

View File

@ -1,32 +0,0 @@
"""добавил тип линзы у содержимого отчета
Revision ID: 15df0d2bfad5
Revises: a5c09be17888
Create Date: 2025-02-20 19:51:20.196094
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '15df0d2bfad5'
down_revision: Union[str, None] = 'a5c09be17888'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('set_contents', sa.Column('type_id', sa.Integer(), nullable=False))
op.create_foreign_key(None, 'set_contents', 'lens_types', ['type_id'], ['id'])
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'set_contents', type_='foreignkey')
op.drop_column('set_contents', 'type_id')
# ### end Alembic commands ###

View File

@ -1,92 +0,0 @@
"""Вынес одинаковые поля в базовую модель
Revision ID: 27fa11120115
Revises: 70eb3c307702
Create Date: 2025-02-20 09:51:06.021893
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '27fa11120115'
down_revision: Union[str, None] = '70eb3c307702'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('appointment_files', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('appointment_files', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('appointment_types', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('appointment_types', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('appointments', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('appointments', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('lens', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('lens', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('lens_issues', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('lens_issues', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('lens_types', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('lens_types', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('mailing', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('mailing', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('mailing_delivery_methods', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('mailing_delivery_methods', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('mailing_options', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('mailing_options', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('patients', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('patients', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('recipients', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('recipients', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('roles', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('roles', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('set_contents', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('set_contents', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('set_lens', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('set_lens', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('sets', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('sets', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('users', sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
op.add_column('users', sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'updated_at')
op.drop_column('users', 'created_at')
op.drop_column('sets', 'updated_at')
op.drop_column('sets', 'created_at')
op.drop_column('set_lens', 'updated_at')
op.drop_column('set_lens', 'created_at')
op.drop_column('set_contents', 'updated_at')
op.drop_column('set_contents', 'created_at')
op.drop_column('roles', 'updated_at')
op.drop_column('roles', 'created_at')
op.drop_column('recipients', 'updated_at')
op.drop_column('recipients', 'created_at')
op.drop_column('patients', 'updated_at')
op.drop_column('patients', 'created_at')
op.drop_column('mailing_options', 'updated_at')
op.drop_column('mailing_options', 'created_at')
op.drop_column('mailing_delivery_methods', 'updated_at')
op.drop_column('mailing_delivery_methods', 'created_at')
op.drop_column('mailing', 'updated_at')
op.drop_column('mailing', 'created_at')
op.drop_column('lens_types', 'updated_at')
op.drop_column('lens_types', 'created_at')
op.drop_column('lens_issues', 'updated_at')
op.drop_column('lens_issues', 'created_at')
op.drop_column('lens', 'updated_at')
op.drop_column('lens', 'created_at')
op.drop_column('appointments', 'updated_at')
op.drop_column('appointments', 'created_at')
op.drop_column('appointment_types', 'updated_at')
op.drop_column('appointment_types', 'created_at')
op.drop_column('appointment_files', 'updated_at')
op.drop_column('appointment_files', 'created_at')
# ### end Alembic commands ###

View File

@ -1,40 +0,0 @@
"""убрал таблицу связывающую линзы и наборы
Revision ID: 429c0003ac73
Revises: e2c127e2d330
Create Date: 2025-02-27 10:49:13.829256
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision: str = '429c0003ac73'
down_revision: Union[str, None] = 'e2c127e2d330'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('set_lens')
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('set_lens',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('set_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('lens_id', sa.INTEGER(), autoincrement=False, nullable=False),
sa.Column('created_at', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=False),
sa.Column('updated_at', postgresql.TIMESTAMP(), server_default=sa.text('now()'), autoincrement=False, nullable=False),
sa.ForeignKeyConstraint(['lens_id'], ['lens.id'], name='set_lens_lens_id_fkey'),
sa.ForeignKeyConstraint(['set_id'], ['sets.id'], name='set_lens_set_id_fkey'),
sa.PrimaryKeyConstraint('id', name='set_lens_pkey'),
sa.UniqueConstraint('lens_id', name='set_lens_lens_id_key')
)
# ### end Alembic commands ###

View File

@ -1,32 +0,0 @@
"""Починил внешние ключи у таблиц
Revision ID: 463487eaaa57
Revises: 61aeb99662ba
Create Date: 2025-02-06 20:40:11.324094
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '463487eaaa57'
down_revision: Union[str, None] = '61aeb99662ba'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('recipients_patient_id_fkey', 'recipients', type_='foreignkey')
op.create_foreign_key(None, 'recipients', 'patients', ['patient_id'], ['id'])
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'recipients', type_='foreignkey')
op.create_foreign_key('recipients_patient_id_fkey', 'recipients', 'mailing_delivery_methods', ['patient_id'], ['id'])
# ### end Alembic commands ###

View File

@ -1,32 +0,0 @@
"""Initial migrationA
Revision ID: 61aeb99662ba
Revises: f8f3f414b162
Create Date: 2025-02-06 20:37:40.995282
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '61aeb99662ba'
down_revision: Union[str, None] = 'f8f3f414b162'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('mailing_options_option_id_fkey', 'mailing_options', type_='foreignkey')
op.create_foreign_key(None, 'mailing_options', 'mailing_delivery_methods', ['option_id'], ['id'])
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'mailing_options', type_='foreignkey')
op.create_foreign_key('mailing_options_option_id_fkey', 'mailing_options', 'patients', ['option_id'], ['id'])
# ### end Alembic commands ###

View File

@ -1,32 +0,0 @@
"""Переименовал таблицу с типами линз - Шаг 3
Revision ID: 70eb3c307702
Revises: ee12ffac87d7
Create Date: 2025-02-18 11:41:53.344762
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '70eb3c307702'
down_revision: Union[str, None] = 'ee12ffac87d7'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('lens', sa.Column('type_id', sa.Integer(), nullable=False))
op.create_foreign_key(None, 'lens', 'lens_types', ['type_id'], ['id'])
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'lens', type_='foreignkey')
op.drop_column('lens', 'type_id')
# ### end Alembic commands ###

View File

@ -1,44 +0,0 @@
"""Добавил таблицу с содержанием набора
Revision ID: 7d74a745da7a
Revises: c0997c6bf2f1
Create Date: 2025-02-18 11:28:51.401555
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '7d74a745da7a'
down_revision: Union[str, None] = 'c0997c6bf2f1'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('set_contents',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('tor', sa.Integer(), nullable=False),
sa.Column('trial', sa.Integer(), nullable=False),
sa.Column('esa', sa.Integer(), nullable=False),
sa.Column('fvc', sa.Integer(), nullable=False),
sa.Column('preset_refraction', sa.Integer(), nullable=False),
sa.Column('diameter', sa.Integer(), nullable=False),
sa.Column('periphery_toricity', sa.Integer(), nullable=False),
sa.Column('side', sa.Integer(), nullable=False),
sa.Column('count', sa.Integer(), nullable=False),
sa.Column('set_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['set_id'], ['sets.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('set_contents')
# ### end Alembic commands ###

View File

@ -1,32 +0,0 @@
"""Переименовал таблицу с типами линз - Шаг 1
Revision ID: 7f50bd3f0523
Revises: 7d74a745da7a
Create Date: 2025-02-18 11:41:03.926914
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = '7f50bd3f0523'
down_revision: Union[str, None] = '7d74a745da7a'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint('lens_type_id_fkey', 'lens', type_='foreignkey')
op.drop_column('lens', 'type_id')
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('lens', sa.Column('type_id', sa.INTEGER(), autoincrement=False, nullable=False))
op.create_foreign_key('lens_type_id_fkey', 'lens', 'lenses_types', ['type_id'], ['id'])
# ### end Alembic commands ###

View File

@ -1,29 +0,0 @@
"""сделал у содержания набора тип стороны enum
Revision ID: a5c09be17888
Revises: 0249759985c3
Create Date: 2025-02-20 19:39:57.756998
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'a5c09be17888'
down_revision: Union[str, None] = '0249759985c3'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
op.execute("ALTER TABLE set_contents ALTER COLUMN side TYPE sideenum USING CASE "
"WHEN side = 0 THEN 'LEFT'::sideenum "
"WHEN side = 1 THEN 'RIGHT'::sideenum END")
def downgrade() -> None:
op.execute("ALTER TABLE set_contents ALTER COLUMN side TYPE INTEGER USING CASE "
"WHEN side = 'LEFT' THEN 0 "
"WHEN side = 'RIGHT' THEN 1 END")

View File

@ -1,8 +1,8 @@
"""Initial migrationA
"""0001_инициализация
Revision ID: f8f3f414b162
Revision ID: b10579618fb5
Revises:
Create Date: 2025-02-06 20:16:16.961555
Create Date: 2025-03-11 14:37:52.604086
"""
from typing import Sequence, Union
@ -12,7 +12,7 @@ import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'f8f3f414b162'
revision: str = 'b10579618fb5'
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
@ -21,24 +21,29 @@ depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('appointment_types',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.VARCHAR(length=150), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('title')
)
op.create_table('lenses_types',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
op.create_table('lens_types',
sa.Column('title', sa.VARCHAR(length=150), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('title')
)
op.create_table('mailing_delivery_methods',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.VARCHAR(length=200), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('patients',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('first_name', sa.VARCHAR(length=200), nullable=False),
sa.Column('last_name', sa.VARCHAR(length=200), nullable=False),
sa.Column('patronymic', sa.VARCHAR(length=200), nullable=True),
@ -48,23 +53,28 @@ def upgrade() -> None:
sa.Column('phone', sa.VARCHAR(length=25), nullable=True),
sa.Column('diagnosis', sa.String(), nullable=True),
sa.Column('correction', sa.String(), nullable=True),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id')
)
op.create_table('roles',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.VARCHAR(length=150), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('title')
)
op.create_table('sets',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.VARCHAR(length=150), nullable=False),
sa.Column('count', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('title')
)
op.create_table('lens',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('tor', sa.Float(), nullable=False),
sa.Column('trial', sa.Float(), nullable=False),
sa.Column('esa', sa.Float(), nullable=False),
@ -73,85 +83,114 @@ def upgrade() -> None:
sa.Column('diameter', sa.Float(), nullable=False),
sa.Column('periphery_toricity', sa.Float(), nullable=False),
sa.Column('side', sa.Enum('LEFT', 'RIGHT', name='sideenum'), nullable=False),
sa.Column('issued', sa.Boolean(), nullable=False),
sa.Column('type_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['type_id'], ['lenses_types.id'], ),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['type_id'], ['lens_types.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('set_contents',
sa.Column('tor', sa.Float(), nullable=False),
sa.Column('trial', sa.Float(), nullable=False),
sa.Column('esa', sa.Float(), nullable=False),
sa.Column('fvc', sa.Float(), nullable=False),
sa.Column('preset_refraction', sa.Float(), nullable=False),
sa.Column('diameter', sa.Float(), nullable=False),
sa.Column('periphery_toricity', sa.Float(), nullable=False),
sa.Column('side', sa.Enum('LEFT', 'RIGHT', name='sideenum'), nullable=False),
sa.Column('count', sa.Integer(), nullable=False),
sa.Column('type_id', sa.Integer(), nullable=False),
sa.Column('set_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['set_id'], ['sets.id'], ),
sa.ForeignKeyConstraint(['type_id'], ['lens_types.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('users',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('first_name', sa.VARCHAR(length=200), nullable=False),
sa.Column('last_name', sa.VARCHAR(length=200), nullable=False),
sa.Column('patronymic', sa.VARCHAR(length=200), nullable=True),
sa.Column('login', sa.String(), nullable=False),
sa.Column('password', sa.String(), nullable=False),
sa.Column('role_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['role_id'], ['roles.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('login')
)
op.create_table('appointments',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('results', sa.String(), nullable=True),
sa.Column('days_until_the_next_appointment', sa.Integer(), nullable=True),
sa.Column('date', sa.Date(), server_default=sa.text('now()'), nullable=False),
sa.Column('patient_id', sa.Integer(), nullable=False),
sa.Column('doctor_id', sa.Integer(), nullable=False),
sa.Column('type_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['doctor_id'], ['users.id'], ),
sa.ForeignKeyConstraint(['patient_id'], ['patients.id'], ),
sa.ForeignKeyConstraint(['type_id'], ['appointment_types.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('lens_issues',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('issue_date', sa.Date(), nullable=False),
sa.Column('patient_id', sa.Integer(), nullable=False),
sa.Column('doctor_id', sa.Integer(), nullable=False),
sa.Column('lens_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['doctor_id'], ['users.id'], ),
sa.ForeignKeyConstraint(['lens_id'], ['lens.id'], ),
sa.ForeignKeyConstraint(['patient_id'], ['patients.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('mailing',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('text', sa.String(), nullable=False),
sa.Column('title', sa.String(), nullable=False),
sa.Column('datetime', sa.DateTime(), nullable=False),
sa.Column('user_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('set_lens',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('set_id', sa.Integer(), nullable=False),
sa.Column('lens_id', sa.Integer(), nullable=False),
sa.ForeignKeyConstraint(['lens_id'], ['lens.id'], ),
sa.ForeignKeyConstraint(['set_id'], ['sets.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('lens_id')
)
op.create_table('appointment_files',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('file_path', sa.String(), nullable=False),
sa.Column('file_title', sa.String(), nullable=False),
sa.Column('appointment_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['appointment_id'], ['appointments.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('mailing_options',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('option_id', sa.Integer(), nullable=False),
sa.Column('mailing_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['mailing_id'], ['mailing.id'], ),
sa.ForeignKeyConstraint(['option_id'], ['patients.id'], ),
sa.ForeignKeyConstraint(['option_id'], ['mailing_delivery_methods.id'], ),
sa.PrimaryKeyConstraint('id')
)
op.create_table('recipients',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('patient_id', sa.Integer(), nullable=False),
sa.Column('mailing_id', sa.Integer(), nullable=False),
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('created_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.Column('updated_at', sa.DateTime(), server_default=sa.text('now()'), nullable=False),
sa.ForeignKeyConstraint(['mailing_id'], ['mailing.id'], ),
sa.ForeignKeyConstraint(['patient_id'], ['mailing_delivery_methods.id'], ),
sa.ForeignKeyConstraint(['patient_id'], ['patients.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
@ -162,16 +201,16 @@ def downgrade() -> None:
op.drop_table('recipients')
op.drop_table('mailing_options')
op.drop_table('appointment_files')
op.drop_table('set_lens')
op.drop_table('mailing')
op.drop_table('lens_issues')
op.drop_table('appointments')
op.drop_table('users')
op.drop_table('set_contents')
op.drop_table('lens')
op.drop_table('sets')
op.drop_table('roles')
op.drop_table('patients')
op.drop_table('mailing_delivery_methods')
op.drop_table('lenses_types')
op.drop_table('lens_types')
op.drop_table('appointment_types')
# ### end Alembic commands ###

View File

@ -1,30 +0,0 @@
"""добавил таблице с приемами колонку с датой приема
Revision ID: b189446b0f74
Revises: 429c0003ac73
Create Date: 2025-03-11 14:32:31.061063
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'b189446b0f74'
down_revision: Union[str, None] = '429c0003ac73'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('appointments', sa.Column('date', sa.Date(), server_default=sa.text('now()'), nullable=False))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('appointments', 'date')
# ### end Alembic commands ###

View File

@ -1,30 +0,0 @@
"""добавил признак выдачи у линз
Revision ID: c0997c6bf2f1
Revises: 463487eaaa57
Create Date: 2025-02-13 20:35:52.618925
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'c0997c6bf2f1'
down_revision: Union[str, None] = '463487eaaa57'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('lens', sa.Column('issued', sa.Boolean(), nullable=False))
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('lens', 'issued')
# ### end Alembic commands ###

View File

@ -1,84 +0,0 @@
"""Исправил у контента линз у нужных полей int на float
Revision ID: e2c127e2d330
Revises: 15df0d2bfad5
Create Date: 2025-02-27 09:50:29.338115
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'e2c127e2d330'
down_revision: Union[str, None] = '15df0d2bfad5'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('set_contents', 'tor',
existing_type=sa.INTEGER(),
type_=sa.Float(),
existing_nullable=False)
op.alter_column('set_contents', 'trial',
existing_type=sa.INTEGER(),
type_=sa.Float(),
existing_nullable=False)
op.alter_column('set_contents', 'esa',
existing_type=sa.INTEGER(),
type_=sa.Float(),
existing_nullable=False)
op.alter_column('set_contents', 'fvc',
existing_type=sa.INTEGER(),
type_=sa.Float(),
existing_nullable=False)
op.alter_column('set_contents', 'preset_refraction',
existing_type=sa.INTEGER(),
type_=sa.Float(),
existing_nullable=False)
op.alter_column('set_contents', 'diameter',
existing_type=sa.INTEGER(),
type_=sa.Float(),
existing_nullable=False)
op.alter_column('set_contents', 'periphery_toricity',
existing_type=sa.INTEGER(),
type_=sa.Float(),
existing_nullable=False)
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.alter_column('set_contents', 'periphery_toricity',
existing_type=sa.Float(),
type_=sa.INTEGER(),
existing_nullable=False)
op.alter_column('set_contents', 'diameter',
existing_type=sa.Float(),
type_=sa.INTEGER(),
existing_nullable=False)
op.alter_column('set_contents', 'preset_refraction',
existing_type=sa.Float(),
type_=sa.INTEGER(),
existing_nullable=False)
op.alter_column('set_contents', 'fvc',
existing_type=sa.Float(),
type_=sa.INTEGER(),
existing_nullable=False)
op.alter_column('set_contents', 'esa',
existing_type=sa.Float(),
type_=sa.INTEGER(),
existing_nullable=False)
op.alter_column('set_contents', 'trial',
existing_type=sa.Float(),
type_=sa.INTEGER(),
existing_nullable=False)
op.alter_column('set_contents', 'tor',
existing_type=sa.Float(),
type_=sa.INTEGER(),
existing_nullable=False)
# ### end Alembic commands ###

View File

@ -1,42 +0,0 @@
"""Переименовал таблицу с типами линз - Шаг 2
Revision ID: ee12ffac87d7
Revises: 7f50bd3f0523
Create Date: 2025-02-18 11:41:15.961296
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision: str = 'ee12ffac87d7'
down_revision: Union[str, None] = '7f50bd3f0523'
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('lens_types',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('title', sa.VARCHAR(length=150), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('title')
)
op.drop_table('lenses_types')
# ### end Alembic commands ###
def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('lenses_types',
sa.Column('id', sa.INTEGER(), autoincrement=True, nullable=False),
sa.Column('title', sa.VARCHAR(length=150), autoincrement=False, nullable=False),
sa.PrimaryKeyConstraint('id', name='lenses_types_pkey'),
sa.UniqueConstraint('title', name='lenses_types_title_key')
)
op.drop_table('lens_types')
# ### end Alembic commands ###