a ton of fun happened, refactored alot
This commit is contained in:
59
migrations/versions/f741addef1a1_auto_migrate.py
Normal file
59
migrations/versions/f741addef1a1_auto_migrate.py
Normal file
@ -0,0 +1,59 @@
|
||||
"""auto-migrate
|
||||
|
||||
Revision ID: f741addef1a1
|
||||
Revises: 24de4aa78a43
|
||||
Create Date: 2025-06-29 10:16:35.487343
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'f741addef1a1'
|
||||
down_revision = '24de4aa78a43'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('update_images')
|
||||
op.drop_table('plant_updates')
|
||||
with op.batch_alter_table('grow_logs', schema=None) as batch_op:
|
||||
batch_op.add_column(sa.Column('media_id', sa.Integer(), nullable=True))
|
||||
batch_op.create_foreign_key(None, 'media', ['media_id'], ['id'])
|
||||
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
with op.batch_alter_table('grow_logs', schema=None) as batch_op:
|
||||
batch_op.drop_constraint(None, type_='foreignkey')
|
||||
batch_op.drop_column('media_id')
|
||||
|
||||
op.create_table('plant_updates',
|
||||
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('growlog_id', mysql.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('description', mysql.TEXT(), nullable=True),
|
||||
sa.Column('created_at', mysql.DATETIME(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['growlog_id'], ['grow_logs.id'], name=op.f('plant_updates_ibfk_1')),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_collate='utf8mb4_0900_ai_ci',
|
||||
mysql_default_charset='utf8mb4',
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
op.create_table('update_images',
|
||||
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('update_id', mysql.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('media_id', mysql.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('created_at', mysql.DATETIME(), nullable=False),
|
||||
sa.ForeignKeyConstraint(['media_id'], ['media.id'], name=op.f('update_images_ibfk_2')),
|
||||
sa.ForeignKeyConstraint(['update_id'], ['plant_updates.id'], name=op.f('update_images_ibfk_1')),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_collate='utf8mb4_0900_ai_ci',
|
||||
mysql_default_charset='utf8mb4',
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
# ### end Alembic commands ###
|
Reference in New Issue
Block a user