From 3aa9ce6065ca96fc28a18e08c191fa7210349adb Mon Sep 17 00:00:00 2001 From: vanzhiganov Date: Fri, 20 Oct 2017 05:19:07 +0300 Subject: [PATCH] add migration --- migrations/versions/92040f86c12b_.py | 43 ++++++++++++++++++++++++++++ requirements.txt | 1 + wotstats/models/__init__.py | 1 + wotstats/models/rushaccounts.py | 17 +++++++++++ wotstats/views/rush.py | 2 +- 5 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 migrations/versions/92040f86c12b_.py create mode 100644 wotstats/models/rushaccounts.py diff --git a/migrations/versions/92040f86c12b_.py b/migrations/versions/92040f86c12b_.py new file mode 100644 index 0000000..52a7a63 --- /dev/null +++ b/migrations/versions/92040f86c12b_.py @@ -0,0 +1,43 @@ +"""empty message + +Revision ID: 92040f86c12b +Revises: e75eb58a894e +Create Date: 2017-10-20 03:55:16.731533 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '92040f86c12b' +down_revision = 'e75eb58a894e' +branch_labels = None +depends_on = None + + +def upgrade(): + op.create_table( + 'rush', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('at_start', sa.DateTime(), nullable=False), + sa.Column('at_finish', sa.DateTime(), nullable=False), + sa.Column('bet', sa.Integer(), nullable=False), + sa.Column('status', sa.String(length=32), nullable=False), + sa.PrimaryKeyConstraint('id') + ) + + op.create_table( + 'rush_accounts', + sa.Column('id', sa.Integer(), nullable=False), + sa.Column('rush_id', sa.Integer(), nullable=False), + sa.Column('account_id', sa.Integer(), nullable=False), + sa.ForeignKeyConstraint(['account_id'], ['wot_accounts.account_id'], ), + sa.ForeignKeyConstraint(['rush_id'], ['rush.id'], ), + sa.PrimaryKeyConstraint('id') + ) + + +def downgrade(): + op.drop_table('rush_accounts') + op.drop_table('rush') diff --git a/requirements.txt b/requirements.txt index 472b17f..1a0ffed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ flask flask_sqlalchemy Flask-Migrate +Flask-Script validators jsonschema Flask-JWT diff --git a/wotstats/models/__init__.py b/wotstats/models/__init__.py index bb8ff89..3968c4a 100644 --- a/wotstats/models/__init__.py +++ b/wotstats/models/__init__.py @@ -8,3 +8,4 @@ from .userwotdata import UserWotData from .wotaccounts import WotAccounts from .wotaccountsstats import WotAccountsStats from .rush import Rush +from .rushaccounts import RushAccounts diff --git a/wotstats/models/rushaccounts.py b/wotstats/models/rushaccounts.py new file mode 100644 index 0000000..b0c408a --- /dev/null +++ b/wotstats/models/rushaccounts.py @@ -0,0 +1,17 @@ + +from wotstats.database import db + + +class RushAccounts(db.Model): + id = db.Column(db.Integer, primary_key=True) + rush_id = db.Column(db.Integer, db.ForeignKey('rush.id'), nullable=False) + account_id = db.Column(db.Integer, db.ForeignKey('wot_accounts.account_id'), nullable=False) + + def __init__(self, account_id, nickname): + self.account_id = account_id + self.rush_id = rush_id + + def __repr__(self): + return ''.format( + self.rush_id, self.account_id + ) diff --git a/wotstats/views/rush.py b/wotstats/views/rush.py index 41b36b3..1ed6b98 100644 --- a/wotstats/views/rush.py +++ b/wotstats/views/rush.py @@ -10,7 +10,7 @@ from wotstats.database import db from wotstats.models import Rush # from wotstats.lib import parse_wargaming_openid_url -pages_wallet = Blueprint( +pages_rush = Blueprint( 'pages_rush', __name__, url_prefix='/rush', template_folder='templates')