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.
|
||||
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
|
||||
target_metadata = aurweb.schema.metadata
|
||||
|
||||
|
@ -68,6 +64,11 @@ def run_migrations_online():
|
|||
context.run_migrations()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Interpret the config file for Python logging.
|
||||
# This line sets up loggers basically.
|
||||
logging.config.fileConfig(config.config_file_name)
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
|
|
Loading…
Add table
Reference in a new issue