Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
task/50 removed sa.False_ sa.Null, unique with PK
Browse files Browse the repository at this point in the history
  • Loading branch information
YehorI committed Sep 29, 2023
1 parent 9569ca8 commit 43142de
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Initial migration
Revision ID: f49b1a9878de
Revision ID: 129f61d28e39
Revises:
Create Date: 2023-09-28 17:59:38.753868
Create Date: 2023-09-29 11:18:55.166058
"""
from typing import Sequence, Union
Expand All @@ -11,7 +11,7 @@
from alembic import op

# revision identifiers, used by Alembic.
revision: str = 'f49b1a9878de'
revision: str = '129f61d28e39'
down_revision: Union[str, None] = None
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None
Expand All @@ -22,29 +22,26 @@ def upgrade() -> None:
op.create_table('skills',
sa.Column('id', sa.String(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('migrate_to', sa.String(), nullable=True, default=sa.Null),
sa.Column('migrate_to', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('id')
sa.PrimaryKeyConstraint('id')
)
op.create_table('specialization_groups',
sa.Column('id', sa.String(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('migrate_to', sa.String(), nullable=True, default=sa.Null),
sa.Column('migrate_to', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('id')
sa.PrimaryKeyConstraint('id')
)
op.create_table('specializations',
sa.Column('id', sa.String(), nullable=False),
sa.Column('name', sa.String(), nullable=True),
sa.Column('is_other', sa.Boolean(), nullable=False, default=sa.False_),
sa.Column('is_other', sa.Boolean(), nullable=False),
sa.Column('group_id', sa.String(), nullable=True),
sa.Column('migrate_to', sa.String(), nullable=True, default=sa.Null),
sa.Column('migrate_to', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.ForeignKeyConstraint(['group_id'], ['specialization_groups.id'], ),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('id')
sa.PrimaryKeyConstraint('id')
)
op.create_table('specializations_skills',
sa.Column('skill_id', sa.String(), nullable=False),
Expand All @@ -59,7 +56,7 @@ def upgrade() -> None:


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
# ### adjusted ###
op.drop_table('specializations_skills')
op.drop_table('specializations')
op.drop_table('specialization_groups')
Expand Down
16 changes: 8 additions & 8 deletions sapphire/storage/database/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import uuid
from datetime import datetime

from sqlalchemy import Enum, False_, ForeignKey, Null
from sqlalchemy import Enum, ForeignKey
from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column


Expand All @@ -12,20 +12,20 @@ class Base(DeclarativeBase):
class Skill(Base):
__tablename__ = "skills"

id: Mapped[str] = mapped_column(unique=True, primary_key=True)
id: Mapped[str] = mapped_column(primary_key=True)
name: Mapped[str | None]
migrate_to: Mapped[str | None] = mapped_column(default=Null)
migrate_to: Mapped[str | None] = mapped_column(nullable=True)
created_at: Mapped[datetime] = mapped_column(default=datetime.now)


class Specialization(Base):
__tablename__ = "specializations"

id: Mapped[str] = mapped_column(unique=True, primary_key=True)
id: Mapped[str] = mapped_column(primary_key=True)
name: Mapped[str | None]
is_other: Mapped[bool] = mapped_column(default=False_)
is_other: Mapped[bool] = mapped_column(default=False)
group_id: Mapped[str | None] = mapped_column(ForeignKey("specialization_groups.id"))
migrate_to: Mapped[str | None] = mapped_column(default=Null)
migrate_to: Mapped[str | None] = mapped_column(nullable=True)
created_at: Mapped[datetime] = mapped_column(default=datetime.now)


Expand All @@ -41,8 +41,8 @@ class SpecializationsSkills(Base):
class SpecializationGroup(Base):
__tablename__ = "specialization_groups"

id: Mapped[str] = mapped_column(unique=True, primary_key=True)
id: Mapped[str] = mapped_column(primary_key=True)
name: Mapped[str | None]
migrate_to: Mapped[str | None] = mapped_column(default=Null)
migrate_to: Mapped[str | None] = mapped_column(nullable=True)
created_at: Mapped[datetime] = mapped_column(default=datetime.now)

0 comments on commit 43142de

Please sign in to comment.