"""auto

Revision ID: 4d9859ada63b
Revises: 
Create Date: 2025-06-04 06:16:08.829142

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = '4d9859ada63b'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.create_table('plant_common_name',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name'),
    sa.UniqueConstraint('name')
    )
    op.create_table('tag',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name'),
    sa.UniqueConstraint('name')
    )
    op.create_table('users',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('email', sa.String(length=120), nullable=False),
    sa.Column('password_hash', sa.Text(), nullable=False),
    sa.Column('role', sa.String(length=50), nullable=True),
    sa.Column('is_verified', sa.Boolean(), nullable=True),
    sa.Column('excluded_from_analytics', sa.Boolean(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('email'),
    sa.UniqueConstraint('email')
    )
    op.create_table('plant_scientific_name',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('name', sa.String(length=255), nullable=False),
    sa.Column('common_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['common_id'], ['plant_common_name.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('name'),
    sa.UniqueConstraint('name')
    )
    op.create_table('plant',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('uuid', sa.String(length=36), nullable=False),
    sa.Column('custom_slug', sa.String(length=255), nullable=True),
    sa.Column('owner_id', sa.Integer(), nullable=False),
    sa.Column('common_id', sa.Integer(), nullable=False),
    sa.Column('scientific_id', sa.Integer(), nullable=False),
    sa.Column('plant_type', sa.String(length=50), nullable=False),
    sa.Column('status', sa.String(length=50), nullable=False),
    sa.Column('notes', sa.Text(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.Column('transferred', sa.Boolean(), nullable=True),
    sa.Column('graph_node_id', sa.String(length=255), nullable=True),
    sa.ForeignKeyConstraint(['common_id'], ['plant_common_name.id'], ),
    sa.ForeignKeyConstraint(['owner_id'], ['users.id'], ),
    sa.ForeignKeyConstraint(['scientific_id'], ['plant_scientific_name.id'], ),
    sa.PrimaryKeyConstraint('id'),
    sa.UniqueConstraint('custom_slug'),
    sa.UniqueConstraint('custom_slug'),
    sa.UniqueConstraint('uuid'),
    sa.UniqueConstraint('uuid')
    )
    op.create_table('grow_logs',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('plant_id', sa.Integer(), nullable=False),
    sa.Column('title', sa.String(length=255), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['plant_id'], ['plant.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('plant_lineage',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('child_plant_id', sa.Integer(), nullable=False),
    sa.Column('parent_plant_id', sa.Integer(), nullable=False),
    sa.Column('type', sa.String(length=50), nullable=False),
    sa.ForeignKeyConstraint(['child_plant_id'], ['plant.id'], ),
    sa.ForeignKeyConstraint(['parent_plant_id'], ['plant.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('plant_ownership_log',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('plant_id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('start_time', sa.DateTime(), nullable=False),
    sa.Column('end_time', sa.DateTime(), nullable=True),
    sa.Column('transfer_note', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['plant_id'], ['plant.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('plant_tags',
    sa.Column('plant_id', sa.Integer(), nullable=False),
    sa.Column('tag_id', sa.Integer(), nullable=False),
    sa.ForeignKeyConstraint(['plant_id'], ['plant.id'], ),
    sa.ForeignKeyConstraint(['tag_id'], ['tag.id'], ),
    sa.PrimaryKeyConstraint('plant_id', 'tag_id')
    )
    op.create_table('submissions',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('plant_id', sa.Integer(), nullable=True),
    sa.Column('common_name', sa.String(length=120), nullable=False),
    sa.Column('scientific_name', sa.String(length=120), nullable=True),
    sa.Column('price', sa.Float(), nullable=False),
    sa.Column('source', sa.String(length=120), nullable=True),
    sa.Column('timestamp', sa.DateTime(), nullable=True),
    sa.Column('height', sa.Float(), nullable=True),
    sa.Column('width', sa.Float(), nullable=True),
    sa.Column('leaf_count', sa.Integer(), nullable=True),
    sa.Column('potting_mix', sa.String(length=255), nullable=True),
    sa.Column('container_size', sa.String(length=120), nullable=True),
    sa.Column('health_status', sa.String(length=50), nullable=True),
    sa.Column('notes', sa.Text(), nullable=True),
    sa.ForeignKeyConstraint(['plant_id'], ['plant.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('plant_updates',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('plant_id', sa.Integer(), nullable=False),
    sa.Column('growlog_id', sa.Integer(), nullable=True),
    sa.Column('update_type', sa.String(length=50), nullable=False),
    sa.Column('description', sa.Text(), nullable=True),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['growlog_id'], ['grow_logs.id'], ),
    sa.ForeignKeyConstraint(['plant_id'], ['plant.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('submission_images',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('submission_id', sa.Integer(), nullable=False),
    sa.Column('file_path', sa.String(length=255), nullable=False),
    sa.Column('is_visible', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['submission_id'], ['submissions.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('featured_images',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('submission_image_id', sa.Integer(), nullable=False),
    sa.Column('override_text', sa.String(length=255), nullable=True),
    sa.Column('is_featured', sa.Boolean(), nullable=True),
    sa.ForeignKeyConstraint(['submission_image_id'], ['submission_images.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('image_hearts',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('user_id', sa.Integer(), nullable=False),
    sa.Column('submission_image_id', sa.Integer(), nullable=False),
    sa.Column('created_at', sa.DateTime(), nullable=True),
    sa.ForeignKeyConstraint(['submission_image_id'], ['submission_images.id'], ),
    sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    op.create_table('media',
    sa.Column('id', sa.Integer(), nullable=False),
    sa.Column('file_url', sa.String(length=256), nullable=False),
    sa.Column('uploaded_at', sa.DateTime(), nullable=True),
    sa.Column('plant_id', sa.Integer(), nullable=True),
    sa.Column('growlog_id', sa.Integer(), nullable=True),
    sa.Column('update_id', sa.Integer(), nullable=True),
    sa.Column('caption', sa.String(length=255), nullable=True),
    sa.ForeignKeyConstraint(['growlog_id'], ['grow_logs.id'], ),
    sa.ForeignKeyConstraint(['plant_id'], ['plant.id'], ),
    sa.ForeignKeyConstraint(['update_id'], ['plant_updates.id'], ),
    sa.PrimaryKeyConstraint('id')
    )
    # ### end Alembic commands ###


def downgrade():
    # ### commands auto generated by Alembic - please adjust! ###
    op.drop_table('media')
    op.drop_table('image_hearts')
    op.drop_table('featured_images')
    op.drop_table('submission_images')
    op.drop_table('plant_updates')
    op.drop_table('submissions')
    op.drop_table('plant_tags')
    op.drop_table('plant_ownership_log')
    op.drop_table('plant_lineage')
    op.drop_table('grow_logs')
    op.drop_table('plant')
    op.drop_table('plant_scientific_name')
    op.drop_table('users')
    op.drop_table('tag')
    op.drop_table('plant_common_name')
    # ### end Alembic commands ###
