broke currently
This commit is contained in:
@ -17,10 +17,8 @@ from app import db
|
||||
plugin_model_paths = glob.glob(os.path.join("plugins", "*", "models.py"))
|
||||
|
||||
for path in plugin_model_paths:
|
||||
# e.g. path = "plugins/plant/models.py"
|
||||
# We want to turn that into "plugins.plant.models"
|
||||
rel = path[len("plugins/") : -len("/models.py")] # e.g. "plant"
|
||||
pkg = f"plugins.{rel}.models" # e.g. "plugins.plant.models"
|
||||
rel = path[len("plugins/") : -len("/models.py")]
|
||||
pkg = f"plugins.{rel}.models"
|
||||
try:
|
||||
importlib.import_module(pkg)
|
||||
print(f"✅ Loaded: {pkg}")
|
||||
@ -31,8 +29,8 @@ for path in plugin_model_paths:
|
||||
config = context.config
|
||||
fileConfig(config.config_file_name)
|
||||
logger = logging.getLogger("alembic.env")
|
||||
logger.setLevel(logging.WARN) # optional: silence alembic spam
|
||||
|
||||
# SQLAlchemy will look at this `target_metadata` when autogenerating
|
||||
target_metadata = db.metadata
|
||||
|
||||
def run_migrations_offline():
|
||||
@ -41,13 +39,12 @@ def run_migrations_offline():
|
||||
target_metadata=target_metadata,
|
||||
literal_binds=True,
|
||||
dialect_opts={"paramstyle": "named"},
|
||||
sort_tables=True,
|
||||
render_as_batch=True, # ✅ important!
|
||||
)
|
||||
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:
|
||||
@ -55,10 +52,15 @@ def run_migrations_online():
|
||||
connection=connection,
|
||||
target_metadata=target_metadata,
|
||||
compare_type=True,
|
||||
sort_tables=True,
|
||||
render_as_batch=True, # ✅ important!
|
||||
)
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
print("🧠 Alembic sees these tables:")
|
||||
print(sorted(db.metadata.tables.keys()))
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
|
Reference in New Issue
Block a user