Browse Source

Check if actual plugin migrations exist in migrations directory

Peter Justin 3 years ago
parent
commit
a94c001d8a
1 changed files with 5 additions and 1 deletions
  1. 5 1
      flaskbb/utils/populate.py

+ 5 - 1
flaskbb/utils/populate.py

@@ -394,9 +394,13 @@ def run_plugin_migrations(plugins=None):
 
 
     for plugin in plugins:
     for plugin in plugins:
         plugin_name = current_app.pluggy.get_name(plugin)
         plugin_name = current_app.pluggy.get_name(plugin)
-        if not os.path.exists(os.path.join(plugin.__path__[0], "migrations")):
+
+        migrations_path = os.path.join(plugin.__path__[0], "migrations")
+        has_migrations = len(os.listdir(migrations_path)) != 0
+        if not os.path.exists(migrations_path) or not has_migrations:
             logger.debug("No migrations found for plugin %s" % plugin_name)
             logger.debug("No migrations found for plugin %s" % plugin_name)
             continue
             continue
+
         try:
         try:
             alembic.upgrade(target="{}@head".format(plugin_name))
             alembic.upgrade(target="{}@head".format(plugin_name))
         except CommandError as exc:
         except CommandError as exc: