From b4de82a6e96b850454a0cb0051ab19d617071e9c Mon Sep 17 00:00:00 2001 From: andrei Date: Tue, 11 Mar 2025 14:41:55 +0500 Subject: [PATCH] =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20=D1=81?= =?UTF-8?q?=D0=BA=D0=B2=D0=BE=D1=88=20=D0=BF=D0=B5=D1=80=D0=B2=D1=8B=D1=85?= =?UTF-8?q?=20=D0=BC=D0=B8=D0=B3=D1=80=D0=B0=D1=86=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...убрал_поле_количество_у_таблицы_наборов.py | 30 ----- ..._добавил_тип_линзы_у_содержимого_отчета.py | 32 ------ ..._вынес_одинаковые_поля_в_базовую_модель.py | 92 --------------- ...брал_таблицу_связывающую_линзы_и_наборы.py | 40 ------- ...87eaaa57_починил_внешние_ключи_у_таблиц.py | 32 ------ .../61aeb99662ba_initial_migrationa.py | 32 ------ ...ереименовал_таблицу_с_типами_линз_шаг_3.py | 32 ------ ...7a_добавил_таблицу_с_содержанием_набора.py | 44 ------- ...ереименовал_таблицу_с_типами_линз_шаг_1.py | 32 ------ ...сделал_у_содержания_набора_тип_стороны_.py | 29 ----- ....py => b10579618fb5_0001_инициализация.py} | 107 ++++++++++++------ ...4_добавил_таблице_с_приемами_колонку_с_.py | 30 ----- ...97c6bf2f1_добавил_признак_выдачи_у_линз.py | 30 ----- ...справил_у_контента_линз_у_нужных_полей_.py | 84 -------------- ...ереименовал_таблицу_с_типами_линз_шаг_2.py | 42 ------- 15 files changed, 73 insertions(+), 615 deletions(-) delete mode 100644 api/app/database/migrations/versions/0249759985c3_убрал_поле_количество_у_таблицы_наборов.py delete mode 100644 api/app/database/migrations/versions/15df0d2bfad5_добавил_тип_линзы_у_содержимого_отчета.py delete mode 100644 api/app/database/migrations/versions/27fa11120115_вынес_одинаковые_поля_в_базовую_модель.py delete mode 100644 api/app/database/migrations/versions/429c0003ac73_убрал_таблицу_связывающую_линзы_и_наборы.py delete mode 100644 api/app/database/migrations/versions/463487eaaa57_починил_внешние_ключи_у_таблиц.py delete mode 100644 api/app/database/migrations/versions/61aeb99662ba_initial_migrationa.py delete mode 100644 api/app/database/migrations/versions/70eb3c307702_переименовал_таблицу_с_типами_линз_шаг_3.py delete mode 100644 api/app/database/migrations/versions/7d74a745da7a_добавил_таблицу_с_содержанием_набора.py delete mode 100644 api/app/database/migrations/versions/7f50bd3f0523_переименовал_таблицу_с_типами_линз_шаг_1.py delete mode 100644 api/app/database/migrations/versions/a5c09be17888_сделал_у_содержания_набора_тип_стороны_.py rename api/app/database/migrations/versions/{f8f3f414b162_initial_migrationa.py => b10579618fb5_0001_инициализация.py} (63%) delete mode 100644 api/app/database/migrations/versions/b189446b0f74_добавил_таблице_с_приемами_колонку_с_.py delete mode 100644 api/app/database/migrations/versions/c0997c6bf2f1_добавил_признак_выдачи_у_линз.py delete mode 100644 api/app/database/migrations/versions/e2c127e2d330_исправил_у_контента_линз_у_нужных_полей_.py delete mode 100644 api/app/database/migrations/versions/ee12ffac87d7_переименовал_таблицу_с_типами_линз_шаг_2.py diff --git a/api/app/database/migrations/versions/0249759985c3_убрал_поле_количество_у_таблицы_наборов.py b/api/app/database/migrations/versions/0249759985c3_убрал_поле_количество_у_таблицы_наборов.py deleted file mode 100644 index 9e36f4f..0000000 --- a/api/app/database/migrations/versions/0249759985c3_убрал_поле_количество_у_таблицы_наборов.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/15df0d2bfad5_добавил_тип_линзы_у_содержимого_отчета.py b/api/app/database/migrations/versions/15df0d2bfad5_добавил_тип_линзы_у_содержимого_отчета.py deleted file mode 100644 index 1cce22e..0000000 --- a/api/app/database/migrations/versions/15df0d2bfad5_добавил_тип_линзы_у_содержимого_отчета.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/27fa11120115_вынес_одинаковые_поля_в_базовую_модель.py b/api/app/database/migrations/versions/27fa11120115_вынес_одинаковые_поля_в_базовую_модель.py deleted file mode 100644 index 3cb7874..0000000 --- a/api/app/database/migrations/versions/27fa11120115_вынес_одинаковые_поля_в_базовую_модель.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/429c0003ac73_убрал_таблицу_связывающую_линзы_и_наборы.py b/api/app/database/migrations/versions/429c0003ac73_убрал_таблицу_связывающую_линзы_и_наборы.py deleted file mode 100644 index 35ec254..0000000 --- a/api/app/database/migrations/versions/429c0003ac73_убрал_таблицу_связывающую_линзы_и_наборы.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/463487eaaa57_починил_внешние_ключи_у_таблиц.py b/api/app/database/migrations/versions/463487eaaa57_починил_внешние_ключи_у_таблиц.py deleted file mode 100644 index 4eed1b3..0000000 --- a/api/app/database/migrations/versions/463487eaaa57_починил_внешние_ключи_у_таблиц.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/61aeb99662ba_initial_migrationa.py b/api/app/database/migrations/versions/61aeb99662ba_initial_migrationa.py deleted file mode 100644 index 7266c42..0000000 --- a/api/app/database/migrations/versions/61aeb99662ba_initial_migrationa.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/70eb3c307702_переименовал_таблицу_с_типами_линз_шаг_3.py b/api/app/database/migrations/versions/70eb3c307702_переименовал_таблицу_с_типами_линз_шаг_3.py deleted file mode 100644 index 35bbc2d..0000000 --- a/api/app/database/migrations/versions/70eb3c307702_переименовал_таблицу_с_типами_линз_шаг_3.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/7d74a745da7a_добавил_таблицу_с_содержанием_набора.py b/api/app/database/migrations/versions/7d74a745da7a_добавил_таблицу_с_содержанием_набора.py deleted file mode 100644 index 602182c..0000000 --- a/api/app/database/migrations/versions/7d74a745da7a_добавил_таблицу_с_содержанием_набора.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/7f50bd3f0523_переименовал_таблицу_с_типами_линз_шаг_1.py b/api/app/database/migrations/versions/7f50bd3f0523_переименовал_таблицу_с_типами_линз_шаг_1.py deleted file mode 100644 index 69b056a..0000000 --- a/api/app/database/migrations/versions/7f50bd3f0523_переименовал_таблицу_с_типами_линз_шаг_1.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/a5c09be17888_сделал_у_содержания_набора_тип_стороны_.py b/api/app/database/migrations/versions/a5c09be17888_сделал_у_содержания_набора_тип_стороны_.py deleted file mode 100644 index 63d76a5..0000000 --- a/api/app/database/migrations/versions/a5c09be17888_сделал_у_содержания_набора_тип_стороны_.py +++ /dev/null @@ -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") diff --git a/api/app/database/migrations/versions/f8f3f414b162_initial_migrationa.py b/api/app/database/migrations/versions/b10579618fb5_0001_инициализация.py similarity index 63% rename from api/app/database/migrations/versions/f8f3f414b162_initial_migrationa.py rename to api/app/database/migrations/versions/b10579618fb5_0001_инициализация.py index 0f95cf0..b42be33 100644 --- a/api/app/database/migrations/versions/f8f3f414b162_initial_migrationa.py +++ b/api/app/database/migrations/versions/b10579618fb5_0001_инициализация.py @@ -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 ### diff --git a/api/app/database/migrations/versions/b189446b0f74_добавил_таблице_с_приемами_колонку_с_.py b/api/app/database/migrations/versions/b189446b0f74_добавил_таблице_с_приемами_колонку_с_.py deleted file mode 100644 index 7be30e5..0000000 --- a/api/app/database/migrations/versions/b189446b0f74_добавил_таблице_с_приемами_колонку_с_.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/c0997c6bf2f1_добавил_признак_выдачи_у_линз.py b/api/app/database/migrations/versions/c0997c6bf2f1_добавил_признак_выдачи_у_линз.py deleted file mode 100644 index 89323e9..0000000 --- a/api/app/database/migrations/versions/c0997c6bf2f1_добавил_признак_выдачи_у_линз.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/e2c127e2d330_исправил_у_контента_линз_у_нужных_полей_.py b/api/app/database/migrations/versions/e2c127e2d330_исправил_у_контента_линз_у_нужных_полей_.py deleted file mode 100644 index 1dfd6d3..0000000 --- a/api/app/database/migrations/versions/e2c127e2d330_исправил_у_контента_линз_у_нужных_полей_.py +++ /dev/null @@ -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 ### diff --git a/api/app/database/migrations/versions/ee12ffac87d7_переименовал_таблицу_с_типами_линз_шаг_2.py b/api/app/database/migrations/versions/ee12ffac87d7_переименовал_таблицу_с_типами_линз_шаг_2.py deleted file mode 100644 index 824dce9..0000000 --- a/api/app/database/migrations/versions/ee12ffac87d7_переименовал_таблицу_с_типами_линз_шаг_2.py +++ /dev/null @@ -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 ###