Add migration for Flower

This commit is contained in:
Backend IM Bot 2025-03-27 10:29:17 +00:00
parent c80b21d47e
commit 11985bb10b

View File

@ -0,0 +1,41 @@
"""create flowers table
Revision ID: b2c3d4e5f6g7
Revises:
Create Date: 2023-12-12 10:00:00.000000
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.sql import func
import uuid
# revision identifiers
revision = 'b2c3d4e5f6g7'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
op.create_table(
'flowers',
sa.Column('id', sa.String(), primary_key=True, default=lambda: str(uuid.uuid4())),
sa.Column('name', sa.String(), nullable=False, index=True),
sa.Column('scientific_name', sa.String(), nullable=True),
sa.Column('description', sa.Text(), nullable=True),
sa.Column('color', sa.String(), nullable=True),
sa.Column('bloom_season', sa.String(), nullable=True),
sa.Column('height', sa.Integer(), nullable=True),
sa.Column('sunlight_needs', sa.String(), nullable=True),
sa.Column('water_needs', sa.String(), nullable=True),
sa.Column('is_perennial', sa.Boolean(), default=True),
sa.Column('hardiness_zone', sa.String(), nullable=True),
sa.Column('created_at', sa.DateTime(), server_default=sa.func.now()),
sa.Column('updated_at', sa.DateTime(), server_default=sa.func.now(), onupdate=sa.func.now()),
sa.PrimaryKeyConstraint('id')
)
op.create_index('ix_flowers_name', 'flowers', ['name'])
def downgrade():
op.drop_index('ix_flowers_name', 'flowers')
op.drop_table('flowers')