Fix connection to mysql db

master
Ionut Filip 6 years ago
parent 9077bf7313
commit 2b0a2d561b

@ -8,7 +8,7 @@ RUN mkdir -p /app
WORKDIR /app
COPY requirements-prod.txt requirements.txt
RUN apk add --no-cache libressl curl postgresql-libs\
RUN apk add --no-cache libressl curl postgresql-libs mariadb-connector-c \
&& apk add --no-cache --virtual build-dep \
libressl-dev libffi-dev python3-dev build-base postgresql-dev mariadb-connector-c-dev \
&& pip3 install -r requirements.txt \

@ -72,7 +72,14 @@ def run_migrations_online():
engine = engine_from_config(config.get_section(config.config_ini_section),
prefix='sqlalchemy.',
poolclass=pool.NullPool)
connection = retry(engine.connect, stop=tenacity.stop_after_attempt(100), wait=tenacity.wait_random(min=2, max=5))()
connection = tenacity.Retrying(
stop=tenacity.stop_after_attempt(100),
wait=tenacity.wait_random(min=2, max=5),
before=tenacity.before_log(logging.getLogger("tenacity.retry"), logging.DEBUG),
before_sleep=tenacity.before_sleep_log(logging.getLogger("tenacity.retry"), logging.INFO),
after=tenacity.after_log(logging.getLogger("tenacity.retry"), logging.DEBUG)
).call(engine.connect)
context.configure(connection=connection,
target_metadata=target_metadata,

@ -16,10 +16,10 @@ import sqlalchemy as sa
def upgrade():
with op.batch_alter_table('user') as batch:
batch.alter_column('email', type_=sa.String(length=255))
batch.alter_column('email', type_=sa.String(length=255), nullable=False)
def downgrade():
with op.batch_alter_table('user') as batch:
batch.alter_column('email', type_=sa.String(length=255))
batch.alter_column('email', type_=sa.String(length=255), nullable=False)

@ -43,18 +43,18 @@ def upgrade():
# drop foreign key constraints
with op.batch_alter_table('alias') as batch_op:
batch_op.drop_constraint('alias_domain_name_fkey')
batch_op.drop_constraint('alias_domain_name_fkey', type_='foreignkey')
with op.batch_alter_table('alternative') as batch_op:
batch_op.drop_constraint('alternative_domain_name_fkey')
batch_op.drop_constraint('alternative_domain_name_fkey', type_='foreignkey')
with op.batch_alter_table('manager') as batch_op:
batch_op.drop_constraint('manager_domain_name_fkey')
batch_op.drop_constraint('manager_user_email_fkey')
batch_op.drop_constraint('manager_domain_name_fkey', type_='foreignkey')
batch_op.drop_constraint('manager_user_email_fkey', type_='foreignkey')
with op.batch_alter_table('token') as batch_op:
batch_op.drop_constraint('token_user_email_fkey')
batch_op.drop_constraint('token_user_email_fkey', type_='foreignkey')
with op.batch_alter_table('fetch') as batch_op:
batch_op.drop_constraint('fetch_user_email_fkey')
batch_op.drop_constraint('fetch_user_email_fkey', type_='foreignkey')
with op.batch_alter_table('user') as batch_op:
batch_op.drop_constraint('user_domain_name_fkey')
batch_op.drop_constraint('user_domain_name_fkey', type_='foreignkey')
# lower domain names
for domain in connection.execute(domain_table.select()):

@ -16,13 +16,13 @@ import sqlalchemy as sa
def upgrade():
with op.batch_alter_table('user') as batch:
batch.alter_column('email', type_=sa.String(length=255))
batch.alter_column('email', type_=sa.String(length=255), nullable=False)
with op.batch_alter_table('alias') as batch:
batch.alter_column('email', type_=sa.String(length=255))
batch.alter_column('email', type_=sa.String(length=255), nullable=False)
def downgrade():
with op.batch_alter_table('user') as batch:
batch.alter_column('email', type_=sa.String(length=255))
batch.alter_column('email', type_=sa.String(length=255), nullable=False)
with op.batch_alter_table('alias') as batch:
batch.alter_column('email', type_=sa.String(length=255))
batch.alter_column('email', type_=sa.String(length=255), nullable=False)

Loading…
Cancel
Save