Major fixes and new features
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2025-09-25 15:51:48 +09:00
parent dd7349bb4c
commit ddce9f5125
5586 changed files with 1470941 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
"""rename_relationship_to_relation_type
Revision ID: 2a4784830015
Revises: 2ede6d343f7c
Create Date: 2025-09-25 15:20:07.573393
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2a4784830015'
down_revision = '2ede6d343f7c'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Переименовываем столбец relationship в relation_type
op.alter_column('emergency_contacts', 'relationship', new_column_name='relation_type')
def downgrade() -> None:
# Возвращаем исходное название
op.alter_column('emergency_contacts', 'relation_type', new_column_name='relationship')

View File

@@ -0,0 +1,24 @@
"""rename_relationship_to_relation_type
Revision ID: 2ede6d343f7c
Revises: c78a12db4567
Create Date: 2025-09-25 15:19:34.244622
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '2ede6d343f7c'
down_revision = 'c78a12db4567'
branch_labels = None
depends_on = None
def upgrade() -> None:
pass
def downgrade() -> None:
pass

View File

@@ -0,0 +1,34 @@
"""add_username_to_users_table
Revision ID: 49846a45b6b0
Revises: 050c22851c2d
Create Date: 2025-09-25 14:11:11.985379
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '49846a45b6b0'
down_revision = '050c22851c2d'
branch_labels = None
depends_on = None
def upgrade() -> None:
# Добавляем колонку username в таблицу users
op.add_column('users', sa.Column('username', sa.String(50), nullable=True, unique=True, index=True))
# Заполняем значения username на основе email (первая часть до @)
op.execute("""
UPDATE users
SET username = split_part(email, '@', 1)
""")
# В будущем можно сделать эту колонку not null, но пока оставим nullable
def downgrade() -> None:
# Удаляем колонку username из таблицы users
op.drop_column('users', 'username')

View File

@@ -0,0 +1,56 @@
"""create_emergency_contacts_table
Revision ID: c78a12db4567
Revises: 49846a45b6b0
Create Date: 2025-09-25 16:00:00
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "c78a12db4567"
down_revision = "49846a45b6b0"
branch_labels = None
depends_on = None
def upgrade():
# Создание таблицы emergency_contacts
op.create_table(
"emergency_contacts",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column(
"uuid", postgresql.UUID(as_uuid=True), server_default=sa.text("gen_random_uuid()"), nullable=False
),
sa.Column("user_id", sa.Integer(), nullable=False),
sa.Column("name", sa.String(length=100), nullable=False),
sa.Column("phone_number", sa.String(length=20), nullable=False),
sa.Column("relationship", sa.String(length=50), nullable=True),
sa.Column("notes", sa.Text(), nullable=True),
sa.Column(
"created_at", sa.DateTime(timezone=True), server_default=sa.text("now()"), nullable=False
),
sa.Column(
"updated_at",
sa.DateTime(timezone=True),
server_default=sa.text("now()"),
nullable=False,
),
sa.ForeignKeyConstraint(["user_id"], ["users.id"], ondelete="CASCADE"),
sa.PrimaryKeyConstraint("id"),
)
op.create_index(
op.f("ix_emergency_contacts_uuid"), "emergency_contacts", ["uuid"], unique=True
)
op.create_index(
op.f("ix_emergency_contacts_user_id"), "emergency_contacts", ["user_id"], unique=False
)
def downgrade():
# Удаление таблицы emergency_contacts
op.drop_index(op.f("ix_emergency_contacts_user_id"), table_name="emergency_contacts")
op.drop_index(op.f("ix_emergency_contacts_uuid"), table_name="emergency_contacts")
op.drop_table("emergency_contacts")