API: Activities records init
+ minor db change for Activity
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
"""empty message
|
||||
"""create User table
|
||||
|
||||
Revision ID: 9741fc7834da
|
||||
Revises:
|
||||
|
@ -1,4 +1,4 @@
|
||||
"""empty message
|
||||
"""create Activity & Sport tables
|
||||
|
||||
Revision ID: b7cfe0c17708
|
||||
Revises: 9741fc7834da
|
||||
|
42
mpwo_api/migrations/versions/caf0e0dc621a_.py
Normal file
42
mpwo_api/migrations/versions/caf0e0dc621a_.py
Normal file
@ -0,0 +1,42 @@
|
||||
"""create Record table
|
||||
|
||||
Revision ID: caf0e0dc621a
|
||||
Revises: b7cfe0c17708
|
||||
Create Date: 2018-05-11 22:33:08.267488
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = 'caf0e0dc621a'
|
||||
down_revision = 'b7cfe0c17708'
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def upgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.create_table('records',
|
||||
sa.Column('id', sa.Integer(), nullable=False),
|
||||
sa.Column('user_id', sa.Integer(), nullable=False),
|
||||
sa.Column('sport_id', sa.Integer(), nullable=False),
|
||||
sa.Column('activity_id', sa.Integer(), nullable=False),
|
||||
sa.Column('record_type', sa.Enum('FD', 'LD', 'MS', name='record_types'), nullable=True),
|
||||
sa.Column('activity_date', sa.DateTime(), nullable=False),
|
||||
sa.Column('value_interval', sa.Interval(), nullable=True),
|
||||
sa.Column('value_float', sa.Numeric(precision=5, scale=3), nullable=True),
|
||||
sa.ForeignKeyConstraint(['activity_id'], ['activities.id'], ),
|
||||
sa.ForeignKeyConstraint(['sport_id'], ['sports.id'], ),
|
||||
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
|
||||
sa.PrimaryKeyConstraint('id'),
|
||||
sa.UniqueConstraint('user_id', 'sport_id', 'record_type', name='user_sports_records')
|
||||
)
|
||||
# ### end Alembic commands ###
|
||||
|
||||
|
||||
def downgrade():
|
||||
# ### commands auto generated by Alembic - please adjust! ###
|
||||
op.drop_table('records')
|
||||
# ### end Alembic commands ###
|
Reference in New Issue
Block a user