bunch of changes
This commit is contained in:
1
migrations/README
Normal file
1
migrations/README
Normal file
@ -0,0 +1 @@
|
||||
Single-database configuration for Flask.
|
50
migrations/alembic.ini
Normal file
50
migrations/alembic.ini
Normal file
@ -0,0 +1,50 @@
|
||||
# A generic, single database configuration.
|
||||
|
||||
[alembic]
|
||||
# template used to generate migration files
|
||||
# file_template = %%(rev)s_%%(slug)s
|
||||
|
||||
# set to 'true' to run the environment during
|
||||
# the 'revision' command, regardless of autogenerate
|
||||
# revision_environment = false
|
||||
|
||||
|
||||
# Logging configuration
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic,flask_migrate
|
||||
|
||||
[handlers]
|
||||
keys = console
|
||||
|
||||
[formatters]
|
||||
keys = generic
|
||||
|
||||
[logger_root]
|
||||
level = WARN
|
||||
handlers = console
|
||||
qualname =
|
||||
|
||||
[logger_sqlalchemy]
|
||||
level = WARN
|
||||
handlers =
|
||||
qualname = sqlalchemy.engine
|
||||
|
||||
[logger_alembic]
|
||||
level = INFO
|
||||
handlers =
|
||||
qualname = alembic
|
||||
|
||||
[logger_flask_migrate]
|
||||
level = INFO
|
||||
handlers =
|
||||
qualname = flask_migrate
|
||||
|
||||
[handler_console]
|
||||
class = StreamHandler
|
||||
args = (sys.stderr,)
|
||||
level = NOTSET
|
||||
formatter = generic
|
||||
|
||||
[formatter_generic]
|
||||
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||
datefmt = %H:%M:%S
|
63
migrations/env.py
Normal file
63
migrations/env.py
Normal file
@ -0,0 +1,63 @@
|
||||
from __future__ import with_statement
|
||||
import os
|
||||
import logging
|
||||
import importlib.util
|
||||
from alembic import context
|
||||
from sqlalchemy import engine_from_config, pool
|
||||
from logging.config import fileConfig
|
||||
from flask import current_app
|
||||
from app import db
|
||||
|
||||
# -----------------------------
|
||||
# 🔍 Automatically import all plugin models
|
||||
# -----------------------------
|
||||
import glob
|
||||
import importlib.util
|
||||
|
||||
plugin_model_paths = glob.glob(os.path.join("plugins", "*", "models.py"))
|
||||
|
||||
for path in plugin_model_paths:
|
||||
module_name = path.replace("/", ".").replace(".py", "")
|
||||
try:
|
||||
spec = importlib.util.spec_from_file_location(module_name, path)
|
||||
module = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(module)
|
||||
print(f"✅ Loaded: {module_name}")
|
||||
except Exception as e:
|
||||
print(f"❌ Failed to load {module_name}: {e}")
|
||||
# -----------------------------
|
||||
|
||||
config = context.config
|
||||
fileConfig(config.config_file_name)
|
||||
logger = logging.getLogger('alembic.env')
|
||||
|
||||
target_metadata = db.metadata
|
||||
|
||||
def run_migrations_offline():
|
||||
context.configure(
|
||||
url=current_app.config.get("SQLALCHEMY_DATABASE_URI"),
|
||||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"},
|
||||
)
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
print("🧠 Alembic sees these tables:")
|
||||
print(sorted(db.metadata.tables.keys()))
|
||||
|
||||
def run_migrations_online():
|
||||
connectable = db.engine
|
||||
with connectable.connect() as connection:
|
||||
context.configure(
|
||||
connection=connection,
|
||||
target_metadata=target_metadata,
|
||||
compare_type=True,
|
||||
)
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
24
migrations/script.py.mako
Normal file
24
migrations/script.py.mako
Normal file
@ -0,0 +1,24 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = ${repr(up_revision)}
|
||||
down_revision = ${repr(down_revision)}
|
||||
branch_labels = ${repr(branch_labels)}
|
||||
depends_on = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade():
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade():
|
||||
${downgrades if downgrades else "pass"}
|
28
migrations/versions/0171b270afc1_auto.py
Normal file
28
migrations/versions/0171b270afc1_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 0171b270afc1
|
||||
Revises: 4d9859ada63b
|
||||
Create Date: 2025-06-04 06:20:47.463202
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '0171b270afc1'
|
||||
down_revision = '4d9859ada63b'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/07d152ee2ac2_auto.py
Normal file
28
migrations/versions/07d152ee2ac2_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 07d152ee2ac2
|
||||
Revises: 0171b270afc1
|
||||
Create Date: 2025-06-04 06:24:51.986909
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '07d152ee2ac2'
|
||||
down_revision = '0171b270afc1'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/1c7cef84b4ae_auto.py
Normal file
28
migrations/versions/1c7cef84b4ae_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 1c7cef84b4ae
|
||||
Revises: 26803929dc3e
|
||||
Create Date: 2025-06-04 22:07:43.375613
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '1c7cef84b4ae'
|
||||
down_revision = '26803929dc3e'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.add_column('plant', sa.Column('is_verified', sa.Boolean(), nullable=False))
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_column('plant', 'is_verified')
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/26803929dc3e_auto.py
Normal file
28
migrations/versions/26803929dc3e_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 26803929dc3e
|
||||
Revises: 07d152ee2ac2
|
||||
Create Date: 2025-06-04 06:38:27.377036
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '26803929dc3e'
|
||||
down_revision = '07d152ee2ac2'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/27a65a4e055c_auto.py
Normal file
28
migrations/versions/27a65a4e055c_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 27a65a4e055c
|
||||
Revises: 48d93714beaf
|
||||
Create Date: 2025-06-05 04:23:44.796455
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '27a65a4e055c'
|
||||
down_revision = '48d93714beaf'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/2a0b02a42543_auto.py
Normal file
28
migrations/versions/2a0b02a42543_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 2a0b02a42543
|
||||
Revises: 93b893e47742
|
||||
Create Date: 2025-06-05 02:41:56.741133
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2a0b02a42543'
|
||||
down_revision = '93b893e47742'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/2fa6feb17477_auto.py
Normal file
28
migrations/versions/2fa6feb17477_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 2fa6feb17477
|
||||
Revises: 9cff183551e1
|
||||
Create Date: 2025-06-05 00:45:39.693560
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '2fa6feb17477'
|
||||
down_revision = '9cff183551e1'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/48d93714beaf_auto.py
Normal file
28
migrations/versions/48d93714beaf_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 48d93714beaf
|
||||
Revises: 761d0f8be3ff
|
||||
Create Date: 2025-06-05 04:20:31.030479
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '48d93714beaf'
|
||||
down_revision = '761d0f8be3ff'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/48fee8a8a3be_auto.py
Normal file
28
migrations/versions/48fee8a8a3be_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 48fee8a8a3be
|
||||
Revises: af76c66c9075
|
||||
Create Date: 2025-06-05 00:25:55.439874
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '48fee8a8a3be'
|
||||
down_revision = 'af76c66c9075'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
202
migrations/versions/4d9859ada63b_auto.py
Normal file
202
migrations/versions/4d9859ada63b_auto.py
Normal file
@ -0,0 +1,202 @@
|
||||
"""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 ###
|
28
migrations/versions/50d5ff358f96_auto.py
Normal file
28
migrations/versions/50d5ff358f96_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 50d5ff358f96
|
||||
Revises: 1c7cef84b4ae
|
||||
Create Date: 2025-06-04 22:14:54.902029
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '50d5ff358f96'
|
||||
down_revision = '1c7cef84b4ae'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/58022b5ab921_auto.py
Normal file
28
migrations/versions/58022b5ab921_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 58022b5ab921
|
||||
Revises: 50d5ff358f96
|
||||
Create Date: 2025-06-04 22:32:06.203591
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '58022b5ab921'
|
||||
down_revision = '50d5ff358f96'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
93
migrations/versions/761d0f8be3ff_auto.py
Normal file
93
migrations/versions/761d0f8be3ff_auto.py
Normal file
@ -0,0 +1,93 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 761d0f8be3ff
|
||||
Revises: ad9ea9d31b58
|
||||
Create Date: 2025-06-05 04:18:09.403526
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy.dialects import mysql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '761d0f8be3ff'
|
||||
down_revision = 'ad9ea9d31b58'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('plant_lineage')
|
||||
op.add_column('plant', sa.Column('updated_at', sa.DateTime(), nullable=True))
|
||||
op.drop_column('plant', 'transferred')
|
||||
op.drop_column('plant', 'status')
|
||||
op.drop_column('plant', 'is_verified')
|
||||
op.drop_column('plant', 'graph_node_id')
|
||||
op.drop_column('plant', 'notes')
|
||||
op.add_column('plant_common_name', sa.Column('created_at', sa.DateTime(), nullable=True))
|
||||
op.alter_column('plant_common_name', 'name',
|
||||
existing_type=mysql.VARCHAR(length=255),
|
||||
type_=sa.String(length=128),
|
||||
existing_nullable=False)
|
||||
op.add_column('plant_ownership_log', sa.Column('date_acquired', sa.DateTime(), nullable=True))
|
||||
op.add_column('plant_ownership_log', sa.Column('transferred', sa.Boolean(), nullable=False))
|
||||
op.add_column('plant_ownership_log', sa.Column('graph_node_id', sa.String(length=255), nullable=True))
|
||||
op.add_column('plant_ownership_log', sa.Column('is_verified', sa.Boolean(), nullable=False))
|
||||
op.drop_column('plant_ownership_log', 'start_time')
|
||||
op.drop_column('plant_ownership_log', 'transfer_note')
|
||||
op.drop_column('plant_ownership_log', 'end_time')
|
||||
op.add_column('plant_scientific_name', sa.Column('created_at', sa.DateTime(), nullable=True))
|
||||
op.alter_column('plant_scientific_name', 'name',
|
||||
existing_type=mysql.VARCHAR(length=255),
|
||||
type_=sa.String(length=256),
|
||||
existing_nullable=False)
|
||||
op.alter_column('tag', 'name',
|
||||
existing_type=mysql.VARCHAR(length=255),
|
||||
type_=sa.String(length=128),
|
||||
existing_nullable=False)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.alter_column('tag', 'name',
|
||||
existing_type=sa.String(length=128),
|
||||
type_=mysql.VARCHAR(length=255),
|
||||
existing_nullable=False)
|
||||
op.alter_column('plant_scientific_name', 'name',
|
||||
existing_type=sa.String(length=256),
|
||||
type_=mysql.VARCHAR(length=255),
|
||||
existing_nullable=False)
|
||||
op.drop_column('plant_scientific_name', 'created_at')
|
||||
op.add_column('plant_ownership_log', sa.Column('end_time', mysql.DATETIME(), nullable=True))
|
||||
op.add_column('plant_ownership_log', sa.Column('transfer_note', mysql.TEXT(), nullable=True))
|
||||
op.add_column('plant_ownership_log', sa.Column('start_time', mysql.DATETIME(), nullable=False))
|
||||
op.drop_column('plant_ownership_log', 'is_verified')
|
||||
op.drop_column('plant_ownership_log', 'graph_node_id')
|
||||
op.drop_column('plant_ownership_log', 'transferred')
|
||||
op.drop_column('plant_ownership_log', 'date_acquired')
|
||||
op.alter_column('plant_common_name', 'name',
|
||||
existing_type=sa.String(length=128),
|
||||
type_=mysql.VARCHAR(length=255),
|
||||
existing_nullable=False)
|
||||
op.drop_column('plant_common_name', 'created_at')
|
||||
op.add_column('plant', sa.Column('notes', mysql.TEXT(), nullable=True))
|
||||
op.add_column('plant', sa.Column('graph_node_id', mysql.VARCHAR(length=255), nullable=True))
|
||||
op.add_column('plant', sa.Column('is_verified', mysql.TINYINT(display_width=1), autoincrement=False, nullable=False))
|
||||
op.add_column('plant', sa.Column('status', mysql.VARCHAR(length=50), nullable=False))
|
||||
op.add_column('plant', sa.Column('transferred', mysql.TINYINT(display_width=1), autoincrement=False, nullable=True))
|
||||
op.drop_column('plant', 'updated_at')
|
||||
op.create_table('plant_lineage',
|
||||
sa.Column('id', mysql.INTEGER(), autoincrement=True, nullable=False),
|
||||
sa.Column('child_plant_id', mysql.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('parent_plant_id', mysql.INTEGER(), autoincrement=False, nullable=False),
|
||||
sa.Column('type', mysql.VARCHAR(length=50), nullable=False),
|
||||
sa.ForeignKeyConstraint(['child_plant_id'], ['plant.id'], name=op.f('plant_lineage_ibfk_1')),
|
||||
sa.ForeignKeyConstraint(['parent_plant_id'], ['plant.id'], name=op.f('plant_lineage_ibfk_2')),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
mysql_collate='utf8mb4_0900_ai_ci',
|
||||
mysql_default_charset='utf8mb4',
|
||||
mysql_engine='InnoDB'
|
||||
)
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/806e94a40aeb_auto.py
Normal file
28
migrations/versions/806e94a40aeb_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 806e94a40aeb
|
||||
Revises: e1cdc5f78f5e
|
||||
Create Date: 2025-06-05 01:11:25.968741
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '806e94a40aeb'
|
||||
down_revision = 'e1cdc5f78f5e'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/93b893e47742_auto.py
Normal file
28
migrations/versions/93b893e47742_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 93b893e47742
|
||||
Revises: b783b3b43713
|
||||
Create Date: 2025-06-05 02:37:12.714926
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '93b893e47742'
|
||||
down_revision = 'b783b3b43713'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/9b93a2dffe81_auto.py
Normal file
28
migrations/versions/9b93a2dffe81_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 9b93a2dffe81
|
||||
Revises: c1a4158c8226
|
||||
Create Date: 2025-06-05 01:29:51.402975
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9b93a2dffe81'
|
||||
down_revision = 'c1a4158c8226'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/9cff183551e1_auto.py
Normal file
28
migrations/versions/9cff183551e1_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: 9cff183551e1
|
||||
Revises: 48fee8a8a3be
|
||||
Create Date: 2025-06-05 00:32:07.995675
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = '9cff183551e1'
|
||||
down_revision = '48fee8a8a3be'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/ad9ea9d31b58_auto.py
Normal file
28
migrations/versions/ad9ea9d31b58_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: ad9ea9d31b58
|
||||
Revises: 2a0b02a42543
|
||||
Create Date: 2025-06-05 03:05:30.311725
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'ad9ea9d31b58'
|
||||
down_revision = '2a0b02a42543'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/af76c66c9075_auto.py
Normal file
28
migrations/versions/af76c66c9075_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: af76c66c9075
|
||||
Revises: 58022b5ab921
|
||||
Create Date: 2025-06-04 22:44:12.056714
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'af76c66c9075'
|
||||
down_revision = '58022b5ab921'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/b783b3b43713_auto.py
Normal file
28
migrations/versions/b783b3b43713_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: b783b3b43713
|
||||
Revises: bfc7a6bd8abc
|
||||
Create Date: 2025-06-05 02:07:18.572162
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b783b3b43713'
|
||||
down_revision = 'bfc7a6bd8abc'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/b9c03e1ae0bf_auto.py
Normal file
28
migrations/versions/b9c03e1ae0bf_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: b9c03e1ae0bf
|
||||
Revises: 9b93a2dffe81
|
||||
Create Date: 2025-06-05 01:37:57.483736
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'b9c03e1ae0bf'
|
||||
down_revision = '9b93a2dffe81'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/bfc7a6bd8abc_auto.py
Normal file
28
migrations/versions/bfc7a6bd8abc_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: bfc7a6bd8abc
|
||||
Revises: cc35036a6f94
|
||||
Create Date: 2025-06-05 01:57:23.973531
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'bfc7a6bd8abc'
|
||||
down_revision = 'cc35036a6f94'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/c1a4158c8226_auto.py
Normal file
28
migrations/versions/c1a4158c8226_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: c1a4158c8226
|
||||
Revises: 806e94a40aeb
|
||||
Create Date: 2025-06-05 01:16:54.451574
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'c1a4158c8226'
|
||||
down_revision = '806e94a40aeb'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/cc35036a6f94_auto.py
Normal file
28
migrations/versions/cc35036a6f94_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: cc35036a6f94
|
||||
Revises: b9c03e1ae0bf
|
||||
Create Date: 2025-06-05 01:45:09.251040
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'cc35036a6f94'
|
||||
down_revision = 'b9c03e1ae0bf'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
28
migrations/versions/e1cdc5f78f5e_auto.py
Normal file
28
migrations/versions/e1cdc5f78f5e_auto.py
Normal file
@ -0,0 +1,28 @@
|
||||
"""auto
|
||||
|
||||
Revision ID: e1cdc5f78f5e
|
||||
Revises: 2fa6feb17477
|
||||
Create Date: 2025-06-05 00:57:10.914714
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'e1cdc5f78f5e'
|
||||
down_revision = '2fa6feb17477'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
pass
|
||||
# ### end Alembic commands ###
|
Reference in New Issue
Block a user