mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
move off env.py's active code to __name__ == "__main__"
* Moved migrations/env.py's logging initialization and migration execution into a `__name__ == "__main__"` stanza so it doesn't immediately happen when imported by another module. Signed-off-by: Kevin Morris <kevr@0cost.org>
This commit is contained in:
parent
2df90ce280
commit
7c65604dad
1 changed files with 9 additions and 8 deletions
|
@ -11,10 +11,6 @@ import aurweb.schema
|
||||||
# access to the values within the .ini file in use.
|
# access to the values within the .ini file in use.
|
||||||
config = context.config
|
config = context.config
|
||||||
|
|
||||||
# Interpret the config file for Python logging.
|
|
||||||
# This line sets up loggers basically.
|
|
||||||
logging.config.fileConfig(config.config_file_name)
|
|
||||||
|
|
||||||
# model MetaData for autogenerating migrations
|
# model MetaData for autogenerating migrations
|
||||||
target_metadata = aurweb.schema.metadata
|
target_metadata = aurweb.schema.metadata
|
||||||
|
|
||||||
|
@ -68,7 +64,12 @@ def run_migrations_online():
|
||||||
context.run_migrations()
|
context.run_migrations()
|
||||||
|
|
||||||
|
|
||||||
if context.is_offline_mode():
|
if __name__ == "__main__":
|
||||||
run_migrations_offline()
|
# Interpret the config file for Python logging.
|
||||||
else:
|
# This line sets up loggers basically.
|
||||||
run_migrations_online()
|
logging.config.fileConfig(config.config_file_name)
|
||||||
|
|
||||||
|
if context.is_offline_mode():
|
||||||
|
run_migrations_offline()
|
||||||
|
else:
|
||||||
|
run_migrations_online()
|
||||||
|
|
Loading…
Add table
Reference in a new issue