diff --git a/worblehat/devscripts/seed_test_data.py b/worblehat/devscripts/seed_test_data.py index 567be0f..02cda53 100644 --- a/worblehat/devscripts/seed_test_data.py +++ b/worblehat/devscripts/seed_test_data.py @@ -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() diff --git a/worblehat/models/BookcaseItem.py b/worblehat/models/BookcaseItem.py index 3a26280..e907f1f 100644 --- a/worblehat/models/BookcaseItem.py +++ b/worblehat/models/BookcaseItem.py @@ -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') diff --git a/worblehat/models/migrations/versions/2024-07-28T1412_c3fcf3d979ea_initial_migration.py b/worblehat/models/migrations/versions/2024-07-31T2107_7dfbf8a8dec8_initial_migration.py similarity index 98% rename from worblehat/models/migrations/versions/2024-07-28T1412_c3fcf3d979ea_initial_migration.py rename to worblehat/models/migrations/versions/2024-07-31T2107_7dfbf8a8dec8_initial_migration.py index 06586ac..faedb69 100644 --- a/worblehat/models/migrations/versions/2024-07-28T1412_c3fcf3d979ea_initial_migration.py +++ b/worblehat/models/migrations/versions/2024-07-31T2107_7dfbf8a8dec8_initial_migration.py @@ -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')),