API - remove intermediate directory and rename api directory

This commit is contained in:
Sam
2020-09-16 15:41:02 +02:00
parent 640385cdb7
commit af301b437e
148 changed files with 1953 additions and 1967 deletions

View File

@ -0,0 +1,44 @@
"""create User table
Revision ID: 9741fc7834da
Revises:
Create Date: 2018-01-20 18:59:49.200032
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9741fc7834da'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('users',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('username', sa.String(length=20), nullable=False),
sa.Column('email', sa.String(length=120), nullable=False),
sa.Column('password', sa.String(length=255), nullable=False),
sa.Column('created_at', sa.DateTime(), nullable=False),
sa.Column('admin', sa.Boolean(), nullable=False),
sa.Column('first_name', sa.String(length=80), nullable=True),
sa.Column('last_name', sa.String(length=80), nullable=True),
sa.Column('birth_date', sa.DateTime(), nullable=True),
sa.Column('location', sa.String(length=80), nullable=True),
sa.Column('bio', sa.String(length=200), nullable=True),
sa.Column('picture', sa.String(length=255), nullable=True),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('email'),
sa.UniqueConstraint('username')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('users')
# ### end Alembic commands ###

View File

@ -0,0 +1,59 @@
"""create Activity & Sport tables
Revision ID: b7cfe0c17708
Revises: 9741fc7834da
Create Date: 2018-01-21 17:24:52.587814
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'b7cfe0c17708'
down_revision = '9741fc7834da'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('sports',
sa.Column('id', sa.Integer(), nullable=False),
sa.Column('label', sa.String(length=50), nullable=False),
sa.Column('img', sa.String(length=255), nullable=True),
sa.Column('is_default', sa.Boolean(), default=False, nullable=False),
sa.PrimaryKeyConstraint('id'),
sa.UniqueConstraint('label')
)
op.create_table('activities',
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('title', sa.String(length=255), nullable=True),
sa.Column('gpx', sa.String(length=255), nullable=True),
sa.Column('creation_date', sa.DateTime(), nullable=True),
sa.Column('modification_date', sa.DateTime(), nullable=True),
sa.Column('activity_date', sa.DateTime(), nullable=False),
sa.Column('duration', sa.Interval(), nullable=False),
sa.Column('pauses', sa.Interval(), nullable=True),
sa.Column('moving', sa.Interval(), nullable=True),
sa.Column('distance', sa.Numeric(precision=6, scale=3), nullable=True),
sa.Column('min_alt', sa.Numeric(precision=6, scale=2), nullable=True),
sa.Column('max_alt', sa.Numeric(precision=6, scale=2), nullable=True),
sa.Column('descent', sa.Numeric(precision=7, scale=2), nullable=True),
sa.Column('ascent', sa.Numeric(precision=7, scale=2), nullable=True),
sa.Column('max_speed', sa.Numeric(precision=6, scale=2), nullable=True),
sa.Column('ave_speed', sa.Numeric(precision=6, scale=2), nullable=True),
sa.ForeignKeyConstraint(['sport_id'], ['sports.id'], ),
sa.ForeignKeyConstraint(['user_id'], ['users.id'], ),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('activities')
op.drop_table('sports')
# ### end Alembic commands ###

View File

@ -0,0 +1,41 @@
"""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('AS', 'FD', 'LD', 'MS', name='record_types'), nullable=True),
sa.Column('activity_date', sa.DateTime(), nullable=False),
sa.Column('value', sa.Integer(), 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 ###

View File

@ -0,0 +1,43 @@
"""create Activities Segments table
Revision ID: dd73d23a7a3d
Revises: caf0e0dc621a
Create Date: 2018-05-14 12:12:57.299200
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'dd73d23a7a3d'
down_revision = 'caf0e0dc621a'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('activity_segments',
sa.Column('activity_id', sa.Integer(), nullable=False),
sa.Column('segment_id', sa.Integer(), nullable=False),
sa.Column('duration', sa.Interval(), nullable=False),
sa.Column('pauses', sa.Interval(), nullable=True),
sa.Column('moving', sa.Interval(), nullable=True),
sa.Column('distance', sa.Numeric(precision=6, scale=3), nullable=True),
sa.Column('min_alt', sa.Numeric(precision=6, scale=2), nullable=True),
sa.Column('max_alt', sa.Numeric(precision=6, scale=2), nullable=True),
sa.Column('descent', sa.Numeric(precision=7, scale=2), nullable=True),
sa.Column('ascent', sa.Numeric(precision=7, scale=2), nullable=True),
sa.Column('max_speed', sa.Numeric(precision=6, scale=2), nullable=True),
sa.Column('ave_speed', sa.Numeric(precision=6, scale=2), nullable=True),
sa.ForeignKeyConstraint(['activity_id'], ['activities.id'], ),
sa.PrimaryKeyConstraint('activity_id', 'segment_id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('activity_segments')
# ### end Alembic commands ###

View File

@ -0,0 +1,28 @@
"""add 'bounds' column to 'Activity' table
Revision ID: 92adde6ac0d0
Revises: dd73d23a7a3d
Create Date: 2018-05-14 14:25:04.889189
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = '92adde6ac0d0'
down_revision = 'dd73d23a7a3d'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('activities', sa.Column('bounds', postgresql.ARRAY(sa.Float()), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('activities', 'bounds')
# ### end Alembic commands ###

View File

@ -0,0 +1,30 @@
"""add static map url to 'Activity' table
Revision ID: 5a42db64e872
Revises: 92adde6ac0d0
Create Date: 2018-05-30 10:52:33.433687
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '5a42db64e872'
down_revision = '92adde6ac0d0'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('activities', sa.Column('map', sa.String(length=255), nullable=True))
op.create_unique_constraint(None, 'sports', ['img'])
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_constraint(None, 'sports', type_='unique')
op.drop_column('activities', 'map')
# ### end Alembic commands ###

View File

@ -0,0 +1,28 @@
"""add static map id to 'Activity' table
Revision ID: 9f8c9c37da44
Revises: 5a42db64e872
Create Date: 2018-05-30 12:48:11.714627
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '9f8c9c37da44'
down_revision = '5a42db64e872'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('activities', sa.Column('map_id', sa.String(length=50), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('activities', 'map_id')
# ### end Alembic commands ###

View File

@ -0,0 +1,28 @@
"""add 'timezone' to 'User' table
Revision ID: e82e5e9447de
Revises: 9f8c9c37da44
Create Date: 2018-06-08 16:01:52.684935
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'e82e5e9447de'
down_revision = '9f8c9c37da44'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('users', sa.Column('timezone', sa.String(length=50), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'timezone')
# ### end Alembic commands ###

View File

@ -0,0 +1,30 @@
"""add weather infos in 'Activity' table
Revision ID: 71093ac9ca44
Revises: e82e5e9447de
Create Date: 2018-06-13 15:29:11.715377
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '71093ac9ca44'
down_revision = 'e82e5e9447de'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('activities', sa.Column('weather_end', sa.JSON(), nullable=True))
op.add_column('activities', sa.Column('weather_start', sa.JSON(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('activities', 'weather_start')
op.drop_column('activities', 'weather_end')
# ### end Alembic commands ###

View File

@ -0,0 +1,28 @@
"""Add 'notes' column to 'Activity' table
Revision ID: 096dd0b43beb
Revises: 71093ac9ca44
Create Date: 2018-06-13 17:56:20.359884
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '096dd0b43beb'
down_revision = '71093ac9ca44'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('activities', sa.Column('notes', sa.String(length=500), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('activities', 'notes')
# ### end Alembic commands ###

View File

@ -0,0 +1,28 @@
"""add 'weekm' in 'User' table
Revision ID: 27425324c9e3
Revises: 096dd0b43beb
Create Date: 2019-08-31 15:25:09.412426
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '27425324c9e3'
down_revision = '096dd0b43beb'
branch_labels = None
depends_on = None
def upgrade():
op.add_column('users', sa.Column('weekm', sa.Boolean(create_constraint=50), nullable=True))
op.execute("UPDATE users SET weekm = false")
op.alter_column('users', 'weekm', nullable=False)
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'weekm')
# ### end Alembic commands ###

View File

@ -0,0 +1,28 @@
"""add 'language' to 'User' table
Revision ID: f69f1e413bde
Revises: 27425324c9e3
Create Date: 2019-09-16 13:18:39.198777
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'f69f1e413bde'
down_revision = '27425324c9e3'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('users', sa.Column('language', sa.String(length=50), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('users', 'language')
# ### end Alembic commands ###

View File

@ -0,0 +1,36 @@
"""replace 'is_default' with 'is_active' in 'Sports' table
Revision ID: 1345afe3b11d
Revises: f69f1e413bde
Create Date: 2019-09-22 17:57:00.595775
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '1345afe3b11d'
down_revision = 'f69f1e413bde'
branch_labels = None
depends_on = None
def upgrade():
op.add_column('sports',
sa.Column('is_active',
sa.Boolean(create_constraint=50),
nullable=True))
op.execute("UPDATE sports SET is_active = true")
op.alter_column('sports', 'is_active', nullable=False)
op.drop_column('sports', 'is_default')
def downgrade():
op.add_column('sports',
sa.Column('is_default',
sa.Boolean(create_constraint=50),
nullable=True))
op.execute("UPDATE sports SET is_default = true")
op.alter_column('sports', 'is_default', nullable=False)
op.drop_column('sports', 'is_active')

View File

@ -0,0 +1,35 @@
"""add application config in database
Revision ID: 8a0aad4c838c
Revises: 1345afe3b11d
Create Date: 2019-11-13 13:14:20.147296
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = '8a0aad4c838c'
down_revision = '1345afe3b11d'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.create_table('app_config',
sa.Column('id', sa.Integer(), autoincrement=True, nullable=False),
sa.Column('max_users', sa.Integer(), nullable=False),
sa.Column('gpx_limit_import', sa.Integer(), nullable=False),
sa.Column('max_single_file_size', sa.Integer(), nullable=False),
sa.Column('max_zip_file_size', sa.Integer(), nullable=False),
sa.PrimaryKeyConstraint('id')
)
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_table('app_config')
# ### end Alembic commands ###