CTFd / CTFd

CTFs as you need them

Home Page:https://ctfd.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Plugin database migrations

riccardotornesello opened this issue · comments

Hello, I'm working on a plugin and I need some tables in the database.
Currently, I'm creating the tables with app.db.create_all() but it's not the best approach since it may create conflicts if I have to update the tables.
I checked the documentation and it talks only about this method, without mentioning the migrations even though they are mentioned in the changelog.
How may I create a migration?
I tried running flask db migrate -m "Test migration" from CTFd's directory but then I got this error: Table 'xxxxxxxxxxx' is already defined for this MetaData instance.
If I run the same command from inside the plugin's directory this is what I get: RuntimeError: Working outside of application context.