the manage script returns

This commit is contained in:
deflax 2024-04-01 19:07:45 +03:00
parent b4ab4a392a
commit 98936a066b
2 changed files with 56 additions and 1 deletions

View file

@ -1,7 +1,8 @@
1. Rename *dist.env* to *.env*. Update the environment variables.
2. run osmtile with import script
2. Build the images and run the containers:
3. Build the images and run the containers:
```sh
$ docker-compose up -d --build --remove-orphans ; docker-compose logs -f --timestamps
```
4. Seed db

54
src/forest/manage.py Normal file
View file

@ -0,0 +1,54 @@
#!/usr/bin/env python
import os
from flask.cli import FlaskGroup
from forest import app, db
from forest.models import User
from flask_migrate import Migrate
cli = FlaskGroup(app)
migrate = Migrate()
migrate.init_app(app, db)
@cli.command("create_db")
def create_db():
db.drop_all()
db.create_all()
db.session.commit()
@cli.command("seed_db")
def seed_db():
db.session.add(User(email="daniel@deflax.net"))
db.session.commit()
@cli.command("upgrade_db")
def upgrade_db():
"""Run deployment tasks."""
from flask_migrate import upgrade
from app.models import Role, User
# migrate database to latest revision
upgrade()
# create user roles
Role.insert_roles()
@cli.command("restore_db")
def restore_db(restore_file):
""" recreate db from grid export with python3 manage.py restore /path/grid.tar.bz2 """
print(str(restore_file))
#TODO
from app.models import User
db.session.add(User(email=str(user), password=str(password), confirmed=True, confirmed_on=datetime.datetime.now()))
db.session.commit()
if __name__ == "__main__":
cli()