Skip to content

Commit

Permalink
initial add migrations support
Browse files Browse the repository at this point in the history
  • Loading branch information
F483 committed Sep 10, 2015
1 parent 295a4d9 commit 7076030
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
12 changes: 6 additions & 6 deletions dataserv/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

from sqlalchemy import desc
from dataserv.run import app, db, cache
from dataserv.run import app, db, cache, manager
from dataserv.Farmer import Farmer, AuthError
from dataserv.config import logging

Expand Down Expand Up @@ -202,11 +202,11 @@ def set_height(btc_addr, height):

if __name__ == '__main__': # pragma: no cover
# Create Database
db.create_all()
#db.create_all()

# Run the Flask app
app.run(
host="0.0.0.0",
port=int("5000"),
debug=True
manager.run(
# host="0.0.0.0",
# port=int("5000"),
# debug=True
)
Empty file added dataserv/migrations/empty
Empty file.
14 changes: 14 additions & 0 deletions dataserv/run.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import os
from flask import Flask
from flask.ext.cache import Cache
from flask.ext.sqlalchemy import SQLAlchemy
from flask.ext.script import Manager
from flask.ext.migrate import Migrate, MigrateCommand

# Initialize the Flask application
cache = Cache(config={'CACHE_TYPE': 'simple'})
Expand All @@ -9,3 +12,14 @@
app.config.from_pyfile('config.py')
db = SQLAlchemy(app)
cache.init_app(app)

migrate = Migrate(app, db)

# didn't fix: configparser.NoSectionError: No section: 'alembic'
#migrate = Migrate()
#migrate.init_app(app, db, directory=os.path.join(
# os.path.realpath(os.path.dirname(__file__)), "migrations"
#))

manager = Manager(app)
manager.add_command('db', MigrateCommand)
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ Flask-SQLAlchemy == 2.0
RandomIO == 0.2.1
partialhash == 1.1.0
btctxstore == 4.5.0
Flask-Cache == 0.13.1
Flask-Cache == 0.13.1
Flask-Migrate == 1.5.1

0 comments on commit 7076030

Please sign in to comment.