diff options
| author | Dennis Fink | 2026-11-16 16:21:51 +0100 |
|---|---|---|
| committer | Dennis Fink | 2026-11-16 16:21:51 +0100 |
| commit | 09353e2fd7a66987076f33f65ac4f0fc8831e887 (patch) | |
| tree | 3b2aea952518022a4cd57268b86cf73507ab3440 /webmentions_ssg/__init__.py | |
| parent | 335c27571fa1856a6b775ff51d69d1590273a965 (diff) | |
| download | webmentions-ssg-09353e2fd7a66987076f33f65ac4f0fc8831e887.tar.gz webmentions-ssg-09353e2fd7a66987076f33f65ac4f0fc8831e887.zip | |
fix(core): restrict migrate CLI to development
Hide Flask-Migrate's unrestricted command group unless
`WEBMENTIONS_SSG_DEV` is enabled, while keeping the guarded database
management commands available.
Base migration CLI exposure on the development environment flag rather
than the selected configuration class.
Diffstat (limited to '')
| -rw-r--r-- | webmentions_ssg/__init__.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/webmentions_ssg/__init__.py b/webmentions_ssg/__init__.py index 8e87485..853045d 100644 --- a/webmentions_ssg/__init__.py +++ b/webmentions_ssg/__init__.py @@ -112,6 +112,12 @@ def create_app(config_class: type[DefaultConfig] | None = None) -> Flask: directory=str(Path(__file__).resolve().parent / "migrations"), command="migrate", ) + + # Flask-Migrate always registers its CLI group. Keep its API available for + # the guarded `flask db` commands, but hide the unrestricted CLI outside DEV. + if not development: + app.cli.commands.pop("migrate", None) + csrf.init_app(app) limiter.init_app(app) mail.init_app(app) |
