diff --git a/backend/alembic/versions/9094262a4be3_add_gallery_featuring_columns_to_trees_.py b/backend/alembic/versions/9094262a4be3_add_gallery_featuring_columns_to_trees_.py new file mode 100644 index 00000000..7f4ad683 --- /dev/null +++ b/backend/alembic/versions/9094262a4be3_add_gallery_featuring_columns_to_trees_.py @@ -0,0 +1,40 @@ +"""add gallery featuring columns to trees and script_templates + +Revision ID: 9094262a4be3 +Revises: b09c3789b7e6 +Create Date: 2026-03-19 19:07:25.964399 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '9094262a4be3' +down_revision: Union[str, None] = 'b09c3789b7e6' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # Add gallery featuring columns to trees + op.add_column('trees', sa.Column('is_gallery_featured', sa.Boolean(), nullable=False, server_default=sa.text('false'))) + op.add_column('trees', sa.Column('gallery_sort_order', sa.Integer(), nullable=False, server_default=sa.text('0'))) + op.create_index(op.f('ix_trees_is_gallery_featured'), 'trees', ['is_gallery_featured'], unique=False) + + # Add gallery featuring columns to script_templates + op.add_column('script_templates', sa.Column('is_gallery_featured', sa.Boolean(), nullable=False, server_default=sa.text('false'))) + op.add_column('script_templates', sa.Column('gallery_sort_order', sa.Integer(), nullable=False, server_default=sa.text('0'))) + op.create_index(op.f('ix_script_templates_is_gallery_featured'), 'script_templates', ['is_gallery_featured'], unique=False) + + +def downgrade() -> None: + op.drop_index(op.f('ix_script_templates_is_gallery_featured'), table_name='script_templates') + op.drop_column('script_templates', 'gallery_sort_order') + op.drop_column('script_templates', 'is_gallery_featured') + + op.drop_index(op.f('ix_trees_is_gallery_featured'), table_name='trees') + op.drop_column('trees', 'gallery_sort_order') + op.drop_column('trees', 'is_gallery_featured') diff --git a/backend/app/models/script_template.py b/backend/app/models/script_template.py index 412f72f4..84ddfb19 100644 --- a/backend/app/models/script_template.py +++ b/backend/app/models/script_template.py @@ -65,6 +65,8 @@ class ScriptTemplate(Base): version: Mapped[int] = mapped_column(Integer, nullable=False, default=1) is_verified: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False) is_active: Mapped[bool] = mapped_column(Boolean, nullable=False, default=True) + is_gallery_featured: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False, index=True) + gallery_sort_order: Mapped[int] = mapped_column(Integer, nullable=False, default=0) usage_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0) created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), default=lambda: datetime.now(timezone.utc) diff --git a/backend/app/models/tree.py b/backend/app/models/tree.py index 5b37a552..3557a158 100644 --- a/backend/app/models/tree.py +++ b/backend/app/models/tree.py @@ -85,6 +85,8 @@ class Tree(Base): is_active: Mapped[bool] = mapped_column(Boolean, default=True) is_public: Mapped[bool] = mapped_column(Boolean, default=False, index=True) is_default: Mapped[bool] = mapped_column(Boolean, default=False, index=True) + is_gallery_featured: Mapped[bool] = mapped_column(Boolean, default=False, index=True) + gallery_sort_order: Mapped[int] = mapped_column(Integer, default=0) visibility: Mapped[str] = mapped_column( String(20), nullable=False,