Skip to content

Commit

Permalink
add migrate for db update
Browse files Browse the repository at this point in the history
  • Loading branch information
Jin-Sun-tts committed Mar 13, 2024
1 parent 2e86055 commit 8d1e08a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 15 deletions.
10 changes: 6 additions & 4 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
from flask import Flask
from .models import db
from flask_migrate import Migrate
import os

DATABASE_URI = os.getenv('DATABASE_URI')

def create_app():
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'postgresql://myuser:mypassword@db/mydb'
app.config['SECRET_KEY'] = '12345678'
app.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI
db.init_app(app)

with app.app_context():
db.create_all()
migrate = Migrate(app, db)

# with app.app_context():
# db.create_all()

from .routes import register_routes
register_routes(app)
Expand Down
5 changes: 3 additions & 2 deletions app/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
mod = Blueprint('harvest', __name__)
db = HarvesterDBInterface()

@mod.route('/index', methods=['GET'])
@mod.route('/', methods=['GET'])
def index():
return render_template('index.html')

Expand Down Expand Up @@ -75,4 +75,5 @@ def get_harvest_error(error_id):
return "provide error_id"

def register_routes(app):
app.register_blueprint(mod, url_prefix='/api')
# app.register_blueprint(mod, url_prefix='/api')
app.register_blueprint(mod)
18 changes: 9 additions & 9 deletions app/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
<body>
<h2>Harvest Actions</h2>
<ul>
<li><a href="/api/add_source">Add Harvest Source</a></li>
<li><a href="/api/add_job">Add Harvest Job</a></li>
<li><a href="/api/add_error">Add Harvest Error</a></li>
<li><a href="/api/harvest_sources">Get All Harvest Sources</a></li>
<li><a href="/api/harvest_jobs">Get All Harvest Jobs</a></li>
<li><a href="/api/harvest_errors_by_job/<job_id>">Get All Harvest Errors By Job</a></li>
<li><a href="/api/harvest_source/<source_id>">Get Harvest Source</a></li>
<li><a href="/api/harvest_job/<job_id>">Get Harvest Job</a></li>
<li><a href="/api/harvest_error/<error_id>">Get Harvest Error</a></li>
<li><a href="/add_source">Add Harvest Source</a></li>
<li><a href="/add_job">Add Harvest Job</a></li>
<li><a href="/add_error">Add Harvest Error</a></li>
<li><a href="/harvest_sources">Get All Harvest Sources</a></li>
<li><a href="/harvest_jobs">Get All Harvest Jobs</a></li>
<li><a href="/harvest_errors_by_job/<job_id>">Get All Harvest Errors By Job</a></li>
<li><a href="/harvest_source/<source_id>">Get Harvest Source</a></li>
<li><a href="/harvest_job/<job_id>">Get Harvest Job</a></li>
<li><a href="/harvest_error/<error_id>">Get Harvest Error</a></li>
</ul>
</body>
</html>
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ services:
build: .
depends_on:
- db
volumes:
- .:/app
environment:
DATABASE_URI: ${DATABASE_URI}
FLASK_APP: run.py
Expand Down

1 comment on commit 8d1e08a

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage

Coverage Report
FileStmtsMissCoverMissing
harvester
   __init__.py10100% 
   ckan_utils.py4222 95%
   harvest.py4116767 84%
   utils.py4377 84%
TOTAL4977685% 

Tests Skipped Failures Errors Time
22 0 💤 0 ❌ 0 🔥 1.777s ⏱️

Please sign in to comment.