Compare commits

..

10 Commits

Author SHA1 Message Date
Ferdinand Thiessen 0b5b73edc3 fix(migrations): Fix rebase issues
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/pr/test Pipeline was successful Details
2022-02-23 15:12:45 +01:00
Ferdinand Thiessen aeb4c39a12 fix(app): Skip plugins with not satisfied dependencies.
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/pr/test Pipeline was successful Details
2022-02-23 00:04:49 +01:00
Ferdinand Thiessen a9674d68ab fix(plugins): Fix plugin version for plugin list API endpoint 2022-02-23 00:04:49 +01:00
Ferdinand Thiessen f0751a3cc5 feat(cli): Added CLI command for handling plugins
* Install / Uninstall plugins
* List plugins
2022-02-23 00:04:49 +01:00
Ferdinand Thiessen a356ef99b7 feat(plugins): Identify plugins by id, migrations must be provided at defined location, add utils for plugin functions 2022-02-23 00:04:47 +01:00
Ferdinand Thiessen d1114db06b feat(docs): Add documentation on how to install tables
Also various documentation fixed and improvments
2022-02-22 23:54:57 +01:00
Ferdinand Thiessen b250569718 feat(db): Add migrations support to plugins
* Add initial migrations for core Flaschengeist
* Add migrations to balance
* Add migrations to pricelist
2022-02-22 23:51:31 +01:00
Ferdinand Thiessen f82f81e09e fix(db): Add __repr__ to custom column types, same as done by SQLAlchemy 2022-02-22 23:50:44 +01:00
Ferdinand Thiessen bb92f15636 feat(db): Add database migration support, implements #19
Migrations allow us to keep track of database changes and upgrading databases if needed.
2022-02-22 23:50:41 +01:00
Ferdinand Thiessen 3589564b7f feat(plugins): Load metadata from entry points / distribution
ci/woodpecker/push/lint Pipeline was successful Details
ci/woodpecker/push/test Pipeline was successful Details
ci/woodpecker/pr/lint Pipeline was successful Details
ci/woodpecker/pr/test Pipeline was successful Details
2022-02-22 11:12:33 +01:00
4 changed files with 23 additions and 61 deletions

3
.gitignore vendored
View File

@ -67,8 +67,7 @@ instance/
# Sphinx documentation
docs/_build/
# pdoc
docs/html
docs/
# PyBuilder
target/

View File

@ -1,57 +0,0 @@
# Plugin Development
## File Structure
- your_plugin/
- __init__.py
- ...
- migrations/ (optional)
- ...
- setup.cfg
The basic layout of a plugin is quite simple, you will only need the `setup.cfg` or `setup.py` and
the package containing your plugin code, at lease a `__init__.py` file with your `Plugin` class.
If you use custom database tables you need to provide a `migrations` directory within your package,
see next section.
## Database Tables / Migrations
To allow upgrades of installed plugins, the database is versioned and handled
through [Alembic](https://alembic.sqlalchemy.org/en/latest/index.html) migrations.
Each plugin, which uses custom database tables, is represented as an other base.
So you could simply follow the Alembic tutorial on [how to work with multiple bases](https://alembic.sqlalchemy.org/en/latest/branches.html#creating-a-labeled-base-revision).
A quick overview on how to work with migrations for your plugin:
$ flaschengeist db revision -m "Create my super plugin" \
--head=base --branch-label=myplugin_name --version-path=your/plugin/migrations
This would add a new base named `myplugin_name`, which should be the same as the pypi name of you plugin.
If your tables depend on an other plugin or a specific base version you could of cause add
--depends-on=VERSION
or
--depends-on=other_plugin
### Plugin Removal and Database Tables
As generic downgrades are most often hard to write, your plugin is not required to provide such functionallity.
For Flaschengeist only instable versions provide meaningful downgrade migrations down to the latest stable version.
So this means if you do not provide downgrades you must at lease provide a series of migrations toward removal of
the database tables in case the users wants to delete the plugin.
(base) ----> 1.0 <----> 1.1 <----> 1.2
|
--> removal
After the removal step the database is stamped to to "remove" your
## Useful Hooks
There are some predefined hooks, which might get handy for you.
For more information, please refer to
- `flaschengeist.utils.hook.HookBefore` and
- `flaschengeist.utils.hook.HookAfter`

View File

@ -8,7 +8,7 @@ import subprocess
"--output",
"-o",
help="Documentation output path",
default="./docs/html",
default="./docs",
type=click.Path(file_okay=False, path_type=pathlib.Path),
)
@click.pass_context

View File

@ -1,7 +1,27 @@
"""Flaschengeist Plugins
.. include:: docs/plugin_development.md
## Custom database tables
You can add tables by declaring them using the SQLAlchemy syntax,
then use Alembic to generate migrations for your tables.
This allows Flaschengeist to proper up- or downgrade the
database tables if an user updates your plugin.
migrations have to be provided in a directory called `migrations`
next to your plugin. E.G.
myplugin
- __init__.py
- other/
- ...
- migrations/
## Useful Hooks
There are some predefined hooks, which might get handy for you.
For more information, please refer to
- `flaschengeist.utils.hook.HookBefore` and
- `flaschengeist.utils.hook.HookAfter`
"""
from typing import Optional