change model_id to model
This commit is contained in:
parent
76b2afe94e
commit
b4bb9181a1
5 changed files with 16 additions and 25 deletions
|
@ -1,8 +1,8 @@
|
||||||
"""empty message
|
"""empty message
|
||||||
|
|
||||||
Revision ID: b077aaee9ec8
|
Revision ID: 45f01fb15e26
|
||||||
Revises:
|
Revises:
|
||||||
Create Date: 2019-10-10 17:38:14.900202
|
Create Date: 2019-10-10 17:50:40.846864
|
||||||
|
|
||||||
"""
|
"""
|
||||||
from alembic import op
|
from alembic import op
|
||||||
|
@ -10,7 +10,7 @@ import sqlalchemy as sa
|
||||||
|
|
||||||
|
|
||||||
# revision identifiers, used by Alembic.
|
# revision identifiers, used by Alembic.
|
||||||
revision = 'b077aaee9ec8'
|
revision = '45f01fb15e26'
|
||||||
down_revision = None
|
down_revision = None
|
||||||
branch_labels = None
|
branch_labels = None
|
||||||
depends_on = None
|
depends_on = None
|
||||||
|
@ -70,10 +70,10 @@ def upgrade():
|
||||||
sa.Column('overtime', sa.Enum('BYOYOMI', 'ABSOLUTE', 'HOURGLASS', 'NONE', name='timetypes'), nullable=False),
|
sa.Column('overtime', sa.Enum('BYOYOMI', 'ABSOLUTE', 'HOURGLASS', 'NONE', name='timetypes'), nullable=False),
|
||||||
sa.Column('overtime_period', sa.Integer(), nullable=True),
|
sa.Column('overtime_period', sa.Integer(), nullable=True),
|
||||||
sa.Column('overtime_length', sa.Integer(), nullable=True),
|
sa.Column('overtime_length', sa.Integer(), nullable=True),
|
||||||
sa.Column('game_room_id', sa.Integer(), nullable=True),
|
sa.Column('game_room', sa.Integer(), nullable=True),
|
||||||
sa.Column('player_black', sa.Integer(), nullable=True),
|
sa.Column('player_black', sa.Integer(), nullable=True),
|
||||||
sa.Column('player_white', sa.Integer(), nullable=True),
|
sa.Column('player_white', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['game_room_id'], ['game_rooms.id'], ),
|
sa.ForeignKeyConstraint(['game_room'], ['game_rooms.id'], ),
|
||||||
sa.ForeignKeyConstraint(['player_black'], ['users.id'], ),
|
sa.ForeignKeyConstraint(['player_black'], ['users.id'], ),
|
||||||
sa.ForeignKeyConstraint(['player_white'], ['users.id'], ),
|
sa.ForeignKeyConstraint(['player_white'], ['users.id'], ),
|
||||||
sa.PrimaryKeyConstraint('id')
|
sa.PrimaryKeyConstraint('id')
|
||||||
|
@ -93,18 +93,18 @@ def upgrade():
|
||||||
sa.Column('move_number', sa.Integer(), nullable=True),
|
sa.Column('move_number', sa.Integer(), nullable=True),
|
||||||
sa.Column('is_pass', sa.Boolean(), nullable=False),
|
sa.Column('is_pass', sa.Boolean(), nullable=False),
|
||||||
sa.Column('is_main', sa.Boolean(), nullable=False),
|
sa.Column('is_main', sa.Boolean(), nullable=False),
|
||||||
sa.Column('game_id', sa.Integer(), nullable=False),
|
sa.Column('game', sa.Integer(), nullable=False),
|
||||||
sa.Column('preceding_move_id', sa.Integer(), nullable=True),
|
sa.Column('preceding_move', sa.Integer(), nullable=True),
|
||||||
sa.ForeignKeyConstraint(['game_id'], ['games.id'], ),
|
sa.ForeignKeyConstraint(['game'], ['games.id'], ),
|
||||||
sa.ForeignKeyConstraint(['preceding_move_id'], ['moves.id'], ),
|
sa.ForeignKeyConstraint(['preceding_move'], ['moves.id'], ),
|
||||||
sa.PrimaryKeyConstraint('id')
|
sa.PrimaryKeyConstraint('id')
|
||||||
)
|
)
|
||||||
op.create_table('messages',
|
op.create_table('messages',
|
||||||
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
|
||||||
sa.Column('date', sa.DateTime(), nullable=False),
|
sa.Column('date', sa.DateTime(), nullable=False),
|
||||||
sa.Column('content', sa.String(length=200), nullable=False),
|
sa.Column('content', sa.String(length=200), nullable=False),
|
||||||
sa.Column('move_id', sa.Integer(), nullable=False),
|
sa.Column('move', sa.Integer(), nullable=False),
|
||||||
sa.ForeignKeyConstraint(['move_id'], ['moves.id'], ),
|
sa.ForeignKeyConstraint(['move'], ['moves.id'], ),
|
||||||
sa.PrimaryKeyConstraint('id')
|
sa.PrimaryKeyConstraint('id')
|
||||||
)
|
)
|
||||||
# ### end Alembic commands ###
|
# ### end Alembic commands ###
|
|
@ -55,7 +55,7 @@ class Game(db.Model):
|
||||||
overtime_length = db.Column(db.Integer) # seconds
|
overtime_length = db.Column(db.Integer) # seconds
|
||||||
|
|
||||||
# foreign keys
|
# foreign keys
|
||||||
game_room_id = db.Column(db.Integer, db.ForeignKey("game_rooms.id"))
|
game_room = db.Column(db.Integer, db.ForeignKey("game_rooms.id"))
|
||||||
player_black = db.Column(db.Integer, db.ForeignKey("users.id"))
|
player_black = db.Column(db.Integer, db.ForeignKey("users.id"))
|
||||||
player_white = db.Column(db.Integer, db.ForeignKey("users.id"))
|
player_white = db.Column(db.Integer, db.ForeignKey("users.id"))
|
||||||
|
|
||||||
|
|
|
@ -22,27 +22,18 @@ class GameRoom(db.Model):
|
||||||
private = db.Column(db.Boolean(), nullable=False, default=False)
|
private = db.Column(db.Boolean(), nullable=False, default=False)
|
||||||
language = db.Column(db.Enum(Languages), nullable=False, default=Languages.EN)
|
language = db.Column(db.Enum(Languages), nullable=False, default=Languages.EN)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def __init__(self, name, description, private=False, language=Languages.EN):
|
def __init__(self, name, description, private=False, language=Languages.EN):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.description = description
|
self.description = description
|
||||||
self.private = private
|
self.private = private
|
||||||
self.language = language
|
self.language = language
|
||||||
|
|
||||||
class LanguageSchema(ma.ModelSchema):
|
|
||||||
id = fields.Int()
|
|
||||||
name = fields.Str()
|
|
||||||
iso = fields.Str()
|
|
||||||
|
|
||||||
language_schema = LanguageSchema()
|
|
||||||
|
|
||||||
class RoomSchema(ma.ModelSchema):
|
class RoomSchema(ma.ModelSchema):
|
||||||
id = fields.Int()
|
id = fields.Int()
|
||||||
name = fields.Str()
|
name = fields.Str()
|
||||||
description = fields.Str()
|
description = fields.Str()
|
||||||
private = fields.Bool()
|
private = fields.Bool()
|
||||||
language = fields.Nested(LanguageSchema)
|
language = fields.Str()
|
||||||
|
|
||||||
|
|
||||||
room_schema = RoomSchema()
|
room_schema = RoomSchema()
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Message(db.Model):
|
||||||
content = db.Column(db.String(200), nullable=False)
|
content = db.Column(db.String(200), nullable=False)
|
||||||
|
|
||||||
# foreign key
|
# foreign key
|
||||||
move_id = db.Column(db.Integer, db.ForeignKey("moves.id"), nullable=False)
|
move = db.Column(db.Integer, db.ForeignKey("moves.id"), nullable=False)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
|
@ -19,8 +19,8 @@ class Move(db.Model):
|
||||||
is_main = db.Column(db.Boolean, nullable=False, default=True)
|
is_main = db.Column(db.Boolean, nullable=False, default=True)
|
||||||
|
|
||||||
# foreign keys
|
# foreign keys
|
||||||
game_id = db.Column(db.Integer, db.ForeignKey("games.id"), nullable=False)
|
game = db.Column(db.Integer, db.ForeignKey("games.id"), nullable=False)
|
||||||
preceding_move_id = db.Column(db.Integer, db.ForeignKey("moves.id"))
|
preceding_move = db.Column(db.Integer, db.ForeignKey("moves.id"))
|
||||||
|
|
||||||
succeeding_moves = db.relationship(
|
succeeding_moves = db.relationship(
|
||||||
'Move',
|
'Move',
|
||||||
|
|
Loading…
Reference in a new issue