31 lines
627 B
Python
31 lines
627 B
Python
import os
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
revision = "0003"
|
|
down_revision = "0002"
|
|
branch_labels = None
|
|
depends_on = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
conn = op.get_bind()
|
|
has_data = conn.execute(sa.text("SELECT 1 FROM v3.role LIMIT 1")).scalar()
|
|
|
|
if has_data:
|
|
return
|
|
sql_path = os.path.join(os.path.dirname(__file__), "sql", "0003_initial_data.sql")
|
|
with open(sql_path) as f:
|
|
content = f.read()
|
|
|
|
for stmt in content.split(";\n"):
|
|
stripped = stmt.strip()
|
|
if not stripped:
|
|
continue
|
|
op.execute(stripped)
|
|
|
|
|
|
def downgrade() -> None:
|
|
pass
|