ansible-playbook -i 'ansible/hosts' \
--extra-vars "target_server=stage" \
ansible/main.yml
Global environment should be passed in different ways depending on boot method:
- WSGI via wsgi.py reads
FLASK_ENVvariable and selects appropriate config class. - flask run via console or PyCharm configuration reads
FLASK_APPvar, which should point to app with running config module e.ginformatics_front:create_app('informatics_front.config.DevConfig') - pytest automaticaly runs base
informatics_front.config.TestConfig.
App-specific settings should be provided as env vars along with FLASK_ENV and FLASK_APP. A complete list of supported ones can be found in informatics_front/config.py.
App should be set as pointer to factory method with appropriate config:
FLASK_APP=informatics_front.app_factory:create_app('informatics_front.config.DevConfig')
ejudge;moodle;pynformatics— primary;informatics.
Ensure DB connection string points to primary migration DB. Note /pynformatics at the end.
SQLALCHEMY_DATABASE_URI=mysql+pymysql://root:@localhost/pynformatics
Remove any pre-existing tables:
drop database refresh_token;
We use utf8 character set. Any previously created DB with different charset should be converted:
ALTER DATABASE pynformatics CHARACTER SET utf8 COLLATE utf8_unicode_ci;
Then update to current schema:
flask db upgrade
After modifying models:
# generate new migrations
flask db migrate
# ensure corresponing pkeys and migrate
flask db upgrade
-
Convert
moodle.mdl_statementsto InnoDB (refrenced bycontest_instance):ALTER TABLE moodle.mdl_statements ENGINE = InnoDB;Refrenced tables should be the same engine type (InnoDB) as parent;
-
Ensure all FKey refs are described with correspnding types in migrations:
from sqlalchemy.dialects.mysql import BIGINT ... sa.Column('contest_id', BIGINT(display_width=10, unsigned=True), nullable=True), # <-> foror similar. FKey types should be the same type as PKeys e.g. (
bigint(10) unsigned);
Build and run tests container with provided docker-compose file:
docker-compose --file docker/docker-compose.yml up --force-recreate --abort-on-container-exit --build
If all tests are passed, the Docker process will exit with code 0.jkkkk