#NEWLINE# def revision( config , message = None , autogenerate = False , sql = False ) : #NEWLINE# #INDENT# 'Create a new revision file.' #NEWLINE# script = ScriptDirectory . from_config ( config ) #NEWLINE# template_args = { #NEWLINE# #INDENT# 'config' : config , #NEWLINE# #UNINDENT# } #NEWLINE# imports = set ( ) #NEWLINE# environment = util . asbool ( config . get_main_option ( 'revision_environment' ) ) #NEWLINE# if autogenerate : #NEWLINE# #INDENT# environment = True #NEWLINE# def retrieve_migrations( rev , context ) : #NEWLINE# #INDENT# if ( script . get_revision ( rev ) is not script . get_revision ( 'head' ) ) : #NEWLINE# #INDENT# raise util . CommandError ( 'Target database is not up to date.' ) #NEWLINE# #UNINDENT# autogen . _produce_migration_diffs ( context , template_args , imports ) #NEWLINE# return [ ] #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if environment : #NEWLINE# #INDENT# def retrieve_migrations( rev , context ) : #NEWLINE# #INDENT# return [ ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if environment : #NEWLINE# #INDENT# with EnvironmentContext ( template_args , script , fn = retrieve_migrations , as_sql = sql , template_args = template_args ) : #NEWLINE# #INDENT# script . run_env ( ) #NEWLINE# #UNINDENT# #UNINDENT# script . generate_revision ( util . rev_id ( ) , message , ** template_args )