This commit is contained in:
beabigegg
2025-11-12 22:53:17 +08:00
commit da700721fa
130 changed files with 23393 additions and 0 deletions

View File

@@ -0,0 +1,48 @@
"""
Mark the current migration as complete in alembic_version table
This is needed because tables were partially created before
"""
import pymysql
from app.core.config import settings
# Connect to database
conn = pymysql.connect(
host=settings.mysql_host,
port=settings.mysql_port,
user=settings.mysql_user,
password=settings.mysql_password,
database=settings.mysql_database
)
try:
with conn.cursor() as cursor:
# Check if alembic_version table exists
cursor.execute("SHOW TABLES LIKE 'alembic_version'")
if not cursor.fetchone():
# Create alembic_version table
cursor.execute("""
CREATE TABLE alembic_version (
version_num VARCHAR(32) NOT NULL,
PRIMARY KEY (version_num)
)
""")
print("Created alembic_version table")
# Check current version
cursor.execute("SELECT version_num FROM alembic_version")
current = cursor.fetchone()
if current:
print(f"Current migration version: {current[0]}")
# Delete old version
cursor.execute("DELETE FROM alembic_version")
# Insert new version
cursor.execute(
"INSERT INTO alembic_version (version_num) VALUES ('a7802b126240')"
)
conn.commit()
print("✅ Marked migration a7802b126240 as complete")
finally:
conn.close()