-
Notifications
You must be signed in to change notification settings - Fork 0
Alembic Integration
Asterios Raptis edited this page May 19, 2026
·
2 revisions
Plugins can bring their own database tables with Alembic migration scripts. Alembic is an optional dependency: install it (with SQLAlchemy) separately when you need this integration.
pip install pluginforge alembic sqlalchemyNote: the pluginforge[alembic] extra existed pre-v0.6.0 but was non-functional (it referenced dependencies that were never declared as optional). It was removed in v0.6.0.
Plugins declare their migrations directory by overriding get_migrations_dir():
from pathlib import Path
from pluginforge import BasePlugin
class StoragePlugin(BasePlugin):
name = "storage"
def get_migrations_dir(self) -> str | None:
return str(Path(__file__).parent / "migrations")The PluginManager collects all migration directories from active plugins:
pm = PluginManager("config/app.yaml")
pm.discover_plugins()
migrations = pm.collect_migrations()
# {"storage": "/path/to/storage/migrations", "analytics": "/path/to/analytics/migrations"}Use the collected directories in your Alembic env.py to run migrations from all plugins.
- Plugins that return
Nonefromget_migrations_dir()are skipped - Non-existent directories are logged as warnings and skipped