Changes to enable testing migrations.

This commit is contained in:
philip 2022-01-04 13:36:29 +03:00
parent c04caece8d
commit 7e0737a001
Signed by untrusted user: mango-habanero
GPG Key ID: B00CE9034DA19FB7
3 changed files with 22 additions and 31 deletions

View File

@ -1,10 +1,9 @@
[DATABASE]
user = postgres
[database]
name=cic_notify_test
user=
password=
host=localhost
port = 5432
name = /tmp/cic-notify.db
#engine = postgresql
#driver = psycopg2
port=
engine=sqlite
driver=pysqlite
debug=0

View File

@ -2,7 +2,7 @@
[alembic]
# path to migration scripts
script_location = migrations
script_location = .
# template used to generate migration files
# file_template = %%(rev)s_%%(slug)s
@ -27,28 +27,17 @@ script_location = migrations
# sourceless = false
# version location specification; this defaults
# to migrations/versions. When using multiple version
# to ./versions. When using multiple version
# directories, initial revisions must be specified with --version-path
# version_locations = %(here)s/bar %(here)s/bat migrations/versions
# version_locations = %(here)s/bar %(here)s/bat ./versions
# the output encoding used when revision files
# are written from script.py.mako
# output_encoding = utf-8
sqlalchemy.url = postgres+psycopg2://postgres@localhost/cic-notify
sqlalchemy.url = driver://user:pass@localhost/dbname
[post_write_hooks]
# post_write_hooks defines scripts or Python functions that are run
# on newly generated revision scripts. See the documentation for further
# detail and examples
# format using "black" - use the console_scripts runner, against the "black" entrypoint
# hooks=black
# black.type=console_scripts
# black.entrypoint=black
# black.options=-l 79
# Logging configuration
[loggers]
keys = root,sqlalchemy,alembic

View File

@ -11,7 +11,7 @@ config = context.config
# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)
fileConfig(config.config_file_name, disable_existing_loggers=True)
# add your model's MetaData object here
# for 'autogenerate' support
@ -56,8 +56,11 @@ def run_migrations_online():
and associate a connection with the context.
"""
connectable = context.config.attributes.get("connection", None)
if connectable is None:
connectable = engine_from_config(
config.get_section(config.config_ini_section),
context.config.get_section(context.config.config_ini_section),
prefix="sqlalchemy.",
poolclass=pool.NullPool,
)