models/BookcaseItem: make shelf non-nullable
This commit is contained in:
parent
8161e5e92a
commit
3c4f6ccf8c
|
@ -78,10 +78,10 @@ def main(sql_session):
|
|||
second_half = bookcase_items[half:]
|
||||
|
||||
for item in first_half:
|
||||
item.bookcase_shelf = seed_shelf_1
|
||||
seed_shelf_1.items.add(item)
|
||||
|
||||
for item in second_half:
|
||||
item.bookcase_shelf = seed_shelf_2
|
||||
seed_shelf_2.items.add(item)
|
||||
|
||||
sql_session.add_all(bookcase_items)
|
||||
sql_session.commit()
|
||||
|
|
|
@ -41,7 +41,7 @@ class BookcaseItem(Base, UidMixin):
|
|||
amount: Mapped[int] = mapped_column(SmallInteger, default=1)
|
||||
|
||||
fk_media_type_uid: Mapped[int] = mapped_column(ForeignKey('MediaType.uid'))
|
||||
fk_bookcase_shelf_uid: Mapped[int | None] = mapped_column(ForeignKey('BookcaseShelf.uid'))
|
||||
fk_bookcase_shelf_uid: Mapped[int] = mapped_column(ForeignKey('BookcaseShelf.uid'))
|
||||
fk_language_uid: Mapped[int | None] = mapped_column(ForeignKey('Language.uid'))
|
||||
|
||||
media_type: Mapped[MediaType] = relationship(back_populates='items')
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
"""initial_migration
|
||||
|
||||
Revision ID: c3fcf3d979ea
|
||||
Revision ID: 7dfbf8a8dec8
|
||||
Revises:
|
||||
Create Date: 2024-07-28 14:12:02.772571
|
||||
Create Date: 2024-07-31 21:07:13.434012
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
|
@ -10,7 +10,7 @@ import sqlalchemy as sa
|
|||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c3fcf3d979ea'
|
||||
revision = '7dfbf8a8dec8'
|
||||
down_revision = None
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
@ -85,7 +85,7 @@ def upgrade() -> None:
|
|||
sa.Column('owner', sa.String(), nullable=False),
|
||||
sa.Column('amount', sa.SmallInteger(), nullable=False),
|
||||
sa.Column('fk_media_type_uid', sa.Integer(), nullable=False),
|
||||
sa.Column('fk_bookcase_shelf_uid', sa.Integer(), nullable=True),
|
||||
sa.Column('fk_bookcase_shelf_uid', sa.Integer(), nullable=False),
|
||||
sa.Column('fk_language_uid', sa.Integer(), nullable=True),
|
||||
sa.Column('uid', sa.Integer(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['fk_bookcase_shelf_uid'], ['BookcaseShelf.uid'], name=op.f('fk_BookcaseItem_fk_bookcase_shelf_uid_BookcaseShelf')),
|
Loading…
Reference in New Issue