forked from jessmar94/sportsmatch_api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add GameModel and ResultModel and db creation
- Loading branch information
1 parent
27fa0b1
commit 343f760
Showing
17 changed files
with
268 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
.env | ||
./.vscode | ||
.vscode/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from sqlalchemy import create_engine | ||
from sqlalchemy_utils import database_exists, create_database | ||
|
||
def createdb(database_url): | ||
engine = create_engine(database_url) | ||
if not database_exists(engine.url): | ||
create_database(engine.url) | ||
|
||
print(database_exists(engine.url)) | ||
|
||
def createdb_test(database_url): | ||
engine = create_engine(database_url) | ||
if not database_exists(engine.url): | ||
create_database(engine.url) | ||
|
||
print(database_exists(engine.url)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import os | ||
from flask_script import Manager | ||
from flask_migrate import Migrate, MigrateCommand | ||
from createdb import createdb_test | ||
from dotenv import load_dotenv | ||
load_dotenv() | ||
|
||
from src.app import create_app, db | ||
|
||
createdb_test(os.getenv('TEST_DATABASE_URL')) | ||
|
||
env_name = os.getenv('FLASK_ENV_TEST') | ||
app = create_app(env_name) | ||
|
||
migrate = Migrate(app=app, db=db) | ||
|
||
manager = Manager(app=app) | ||
|
||
manager.add_command('db', MigrateCommand) | ||
|
||
if __name__ == '__main__': | ||
manager.run() |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
"""empty message | ||
Revision ID: cd68d64ae9e2 | ||
Revises: | ||
Create Date: 2019-11-26 00:07:30.437725 | ||
""" | ||
from alembic import op | ||
import sqlalchemy as sa | ||
|
||
|
||
# revision identifiers, used by Alembic. | ||
revision = 'cd68d64ae9e2' | ||
down_revision = None | ||
branch_labels = None | ||
depends_on = None | ||
|
||
|
||
def upgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.create_table('players', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('first_name', sa.String(length=60), nullable=False), | ||
sa.Column('last_name', sa.String(length=60), nullable=False), | ||
sa.Column('email', sa.String(length=128), nullable=False), | ||
sa.Column('password', sa.String(length=128), nullable=False), | ||
sa.Column('gender', sa.String(length=50), nullable=False), | ||
sa.Column('ability', sa.String(length=50), nullable=False), | ||
sa.Column('dob', sa.Date(), nullable=False), | ||
sa.Column('created_at', sa.DateTime(), nullable=True), | ||
sa.Column('modified_at', sa.DateTime(), nullable=True), | ||
sa.PrimaryKeyConstraint('id'), | ||
sa.UniqueConstraint('email') | ||
) | ||
op.create_table('games', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('organiser_id', sa.Integer(), nullable=False), | ||
sa.Column('opponent_id', sa.Integer(), nullable=False), | ||
sa.Column('confirmed', sa.Boolean(), nullable=False), | ||
sa.Column('game_date', sa.Date(), nullable=False), | ||
sa.Column('game_time', sa.Time(), nullable=False), | ||
sa.Column('created_at', sa.DateTime(), nullable=True), | ||
sa.Column('modified_at', sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint(['opponent_id'], ['players.id'], ), | ||
sa.ForeignKeyConstraint(['organiser_id'], ['players.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
op.create_table('results', | ||
sa.Column('id', sa.Integer(), nullable=False), | ||
sa.Column('game_id', sa.Integer(), nullable=False), | ||
sa.Column('winner_id', sa.Integer(), nullable=True), | ||
sa.Column('loser_id', sa.Integer(), nullable=True), | ||
sa.Column('confirmed', sa.Boolean(), nullable=False), | ||
sa.Column('created_at', sa.DateTime(), nullable=True), | ||
sa.Column('modified_at', sa.DateTime(), nullable=True), | ||
sa.ForeignKeyConstraint(['game_id'], ['games.id'], ), | ||
sa.ForeignKeyConstraint(['loser_id'], ['players.id'], ), | ||
sa.ForeignKeyConstraint(['winner_id'], ['players.id'], ), | ||
sa.PrimaryKeyConstraint('id') | ||
) | ||
# ### end Alembic commands ### | ||
|
||
|
||
def downgrade(): | ||
# ### commands auto generated by Alembic - please adjust! ### | ||
op.drop_table('results') | ||
op.drop_table('games') | ||
op.drop_table('players') | ||
# ### end Alembic commands ### |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.