API - remove intermediate directory and rename api directory
This commit is contained in:
1
fittrackee/migrations/README
Executable file
1
fittrackee/migrations/README
Executable file
@ -0,0 +1 @@
|
||||
Generic single-database configuration.
|
45
fittrackee/migrations/alembic.ini
Normal file
45
fittrackee/migrations/alembic.ini
Normal file
@ -0,0 +1,45 @@
|
||||
# A generic, single database configuration.
|
||||
|
||||
[alembic]
|
||||
# template used to generate migration files
|
||||
# file_template = %%(rev)s_%%(slug)s
|
||||
|
||||
# set to 'true' to run the environment during
|
||||
# the 'revision' command, regardless of autogenerate
|
||||
# revision_environment = false
|
||||
|
||||
|
||||
# Logging configuration
|
||||
[loggers]
|
||||
keys = root,sqlalchemy,alembic
|
||||
|
||||
[handlers]
|
||||
keys = console
|
||||
|
||||
[formatters]
|
||||
keys = generic
|
||||
|
||||
[logger_root]
|
||||
level = WARN
|
||||
handlers = console
|
||||
qualname =
|
||||
|
||||
[logger_sqlalchemy]
|
||||
level = WARN
|
||||
handlers =
|
||||
qualname = sqlalchemy.engine
|
||||
|
||||
[logger_alembic]
|
||||
level = INFO
|
||||
handlers =
|
||||
qualname = alembic
|
||||
|
||||
[handler_console]
|
||||
class = StreamHandler
|
||||
args = (sys.stderr,)
|
||||
level = NOTSET
|
||||
formatter = generic
|
||||
|
||||
[formatter_generic]
|
||||
format = %(levelname)-5.5s [%(name)s] %(message)s
|
||||
datefmt = %H:%M:%S
|
88
fittrackee/migrations/env.py
Executable file
88
fittrackee/migrations/env.py
Executable file
@ -0,0 +1,88 @@
|
||||
from __future__ import with_statement
|
||||
from alembic import context
|
||||
from sqlalchemy import engine_from_config, pool
|
||||
from logging.config import fileConfig
|
||||
import logging
|
||||
|
||||
# this is the Alembic Config object, which provides
|
||||
# access to the values within the .ini file in use.
|
||||
config = context.config
|
||||
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
fileConfig(config.config_file_name)
|
||||
logger = logging.getLogger('alembic.env')
|
||||
|
||||
# add your model's MetaData object here
|
||||
# for 'autogenerate' support
|
||||
# from myapp import mymodel
|
||||
# target_metadata = mymodel.Base.metadata
|
||||
from flask import current_app
|
||||
config.set_main_option('sqlalchemy.url',
|
||||
current_app.config.get('SQLALCHEMY_DATABASE_URI'))
|
||||
target_metadata = current_app.extensions['migrate'].db.metadata
|
||||
|
||||
# other values from the config, defined by the needs of env.py,
|
||||
# can be acquired:
|
||||
# my_important_option = config.get_main_option("my_important_option")
|
||||
# ... etc.
|
||||
|
||||
|
||||
def run_migrations_offline():
|
||||
"""Run migrations in 'offline' mode.
|
||||
|
||||
This configures the context with just a URL
|
||||
and not an Engine, though an Engine is acceptable
|
||||
here as well. By skipping the Engine creation
|
||||
we don't even need a DBAPI to be available.
|
||||
|
||||
Calls to context.execute() here emit the given string to the
|
||||
script output.
|
||||
|
||||
"""
|
||||
url = config.get_main_option("sqlalchemy.url")
|
||||
context.configure(url=url)
|
||||
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def run_migrations_online():
|
||||
"""Run migrations in 'online' mode.
|
||||
|
||||
In this scenario we need to create an Engine
|
||||
and associate a connection with the context.
|
||||
|
||||
"""
|
||||
|
||||
# this callback is used to prevent an auto-migration from being generated
|
||||
# when there are no changes to the schema
|
||||
# reference: http://alembic.zzzcomputing.com/en/latest/cookbook.html
|
||||
def process_revision_directives(context, revision, directives):
|
||||
if getattr(config.cmd_opts, 'autogenerate', False):
|
||||
script = directives[0]
|
||||
if script.upgrade_ops.is_empty():
|
||||
directives[:] = []
|
||||
logger.info('No changes in schema detected.')
|
||||
|
||||
engine = engine_from_config(config.get_section(config.config_ini_section),
|
||||
prefix='sqlalchemy.',
|
||||
poolclass=pool.NullPool)
|
||||
|
||||
connection = engine.connect()
|
||||
context.configure(connection=connection,
|
||||
target_metadata=target_metadata,
|
||||
process_revision_directives=process_revision_directives,
|
||||
**current_app.extensions['migrate'].configure_args)
|
||||
|
||||
try:
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
finally:
|
||||
connection.close()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
24
fittrackee/migrations/script.py.mako
Executable file
24
fittrackee/migrations/script.py.mako
Executable file
@ -0,0 +1,24 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
|
||||
"""
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision = ${repr(up_revision)}
|
||||
down_revision = ${repr(down_revision)}
|
||||
branch_labels = ${repr(branch_labels)}
|
||||
depends_on = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade():
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade():
|
||||
${downgrades if downgrades else "pass"}
|
@ -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 ###
|
@ -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 ###
|
@ -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 ###
|
@ -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 ###
|
@ -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 ###
|
@ -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 ###
|
@ -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 ###
|
@ -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 ###
|
@ -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 ###
|
@ -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 ###
|
@ -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 ###
|
@ -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 ###
|
@ -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')
|
@ -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 ###
|
Reference in New Issue
Block a user