Kong / kong-python-pdk

Write Kong plugins in Python (Experimental)
Apache License 2.0
40 stars 14 forks source link

How to handle plugin Schema migrations? #27

Open durvalcarvalho opened 2 years ago

durvalcarvalho commented 2 years ago

Hi guys. I was learning how to create plugins for kong using the python-pdk and it wasn't clear how to handle plugin schema migrations.

From what I understand about lua-pdk, to handle migrations, it's just need to create a migrations directory inside the plugin directory and write the migrations with raw SQL in files in the following format 000_<custom_name>.lua, and in the file init.lua, inside the migrations directory, which I believe is equivalent to python's __init__.py, is necessary to return a set with the filenames in the order they should be applied.

It seems to me that kong already handles the discovery of migration files, and to apply them just run kong's CLI (kong migrations up).

Does this whole process also apply to python-pdk?

fffonion commented 2 years ago

Hi @durvalcarvalho , custom DAO (and migrations) are currently not supported for external plugins. Actually the recommended way to store those custom data outside of plugin config is to use your own datastore, like redis or other database, to more advantage of the nature that those plugins are running outside of Kong.