Adjustment in travis ci configs. Fix importing during first time running db upgrade

This commit is contained in:
Khanh Ngo 2018-08-20 17:21:32 +07:00
parent 0b7580c82f
commit 8af7a6ac9e
No known key found for this signature in database
GPG Key ID: B9AE3BAF6D5A7B22
4 changed files with 24 additions and 5 deletions

View File

@ -2,11 +2,19 @@ language: python
python: python:
- "3.5.2" - "3.5.2"
before_install: before_install:
- 'sudo apt-key adv --fetch-keys http://dl.yarnpkg.com/debian/pubkey.gpg'
- 'echo "deb http://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list'
- 'travis_retry sudo apt-get update' - 'travis_retry sudo apt-get update'
- 'travis_retry sudo apt-get install python3-dev libxml2-dev libxmlsec1-dev' - 'travis_retry sudo apt-get install python3-dev libxml2-dev libxmlsec1-dev yarn'
install: install:
- pip install -r requirements.txt - pip install -r requirements.txt
before_script: before_script:
- mv config_template.py config.py - mv config_template.py config.py
- export FLASK_APP=app/__init__.py
- flask db upgrade
- yarn install --pure-lockfile
- flask assets build
script: script:
- sh run_travis.sh - sh run_travis.sh
cache:
yarn: true

View File

@ -4,6 +4,7 @@ from flask_login import LoginManager
from flask_sqlalchemy import SQLAlchemy as SA from flask_sqlalchemy import SQLAlchemy as SA
from flask_migrate import Migrate from flask_migrate import Migrate
from flask_oauthlib.client import OAuth from flask_oauthlib.client import OAuth
from sqlalchemy.exc import OperationalError
# subclass SQLAlchemy to enable pool_pre_ping # subclass SQLAlchemy to enable pool_pre_ping
class SQLAlchemy(SA): class SQLAlchemy(SA):
@ -35,4 +36,9 @@ if app.config.get('SAML_ENABLED') and app.config.get('SAML_ENCRYPT'):
if not certutil.check_certificate(): if not certutil.check_certificate():
certutil.create_self_signed_cert() certutil.create_self_signed_cert()
from app import models, views from app import models
try:
from app import views
except OperationalError:
logging.error("You have not initialized the DB yet or DB migration is running...")

View File

@ -267,7 +267,7 @@
applyChanges({'domain': domain}, $SCRIPT_ROOT + '/domain/' + domain + '/update'); applyChanges({'domain': domain}, $SCRIPT_ROOT + '/domain/' + domain + '/update');
}); });
{% if SETTING.get('record_helper_setting') %} {% if SETTING.get('record_helper') %}
//handle wacky record types //handle wacky record types
$(document.body).on("focus", "#current_edit_record_data", function (e) { $(document.body).on("focus", "#current_edit_record_data", function (e) {
var record_type = $(this).parents("tr").find('#record_type').val(); var record_type = $(this).parents("tr").find('#record_type').val();

View File

@ -77,6 +77,11 @@ def upgrade():
def downgrade(): def downgrade():
# ### commands auto generated by Alembic - please adjust! ### # ### commands auto generated by Alembic - please adjust! ###
## NOTE:
## - Drop action does not work on sqlite3
## - This action touchs the `setting` table which loaded in views.py
## during app initlization, so the downgrade function won't work
## unless we temporary remove importing `views` from `app/__init__.py`
op.drop_column('setting', 'view') op.drop_column('setting', 'view')
# delete added records in previous version # delete added records in previous version