klen / peewee_migrate

Simple migration engine for Peewee
MIT License
353 stars 86 forks source link

fix: do not read migration template on module import (read it later right before migration) #213

Closed rpodgorny closed 2 years ago

rpodgorny commented 2 years ago

hello,

this patch removes the potentially crashing behaviour of module import on missing template file.

imho, just importing module should have no side effects.

this is how it hit us: 1) our program structure is roughly like this:

import migration

def main():
  init_logging_system_so_that_is_catches_crashes_to_file()
  do_migration()

main()

2) the template.txt file is missing 3) on a headless system (which discards all stderr and stdout) we try to run the program 3) it crashes "silently" without logging any error 4) ...minutes and minutes finding what the hell is going on :-(

...of course the real system is much more complicated but you get the idea.

cc/ @klen

p.s.: if the template is not supposed to be read over and over, let's just store it somewhere in Router instance