#NEWLINE# def setup_database( config_data ) : #NEWLINE# #INDENT# '\n    Run the migrate command to create the database schema\n\n    :param config_data: configuration data\n    ' #NEWLINE# with chdir ( config_data . project_directory ) : #NEWLINE# #INDENT# env = deepcopy ( dict ( os . environ ) ) #NEWLINE# env [ str ( 'DJANGO_SETTINGS_MODULE' ) ] = str ( '{0}.settings' . format ( config_data . project_name ) ) #NEWLINE# env [ str ( 'PYTHONPATH' ) ] = str ( os . pathsep . join ( map ( shlex_quote , sys . path ) ) ) #NEWLINE# commands = [ ] #NEWLINE# commands . append ( [ sys . executable , '-W' , 'ignore' , 'manage.py' , 'migrate' ] ) #NEWLINE# if env . verbose : #NEWLINE# #INDENT# sys . stdout . write ( 'Database setup commands: {0}\n' . format ( ', ' . join ( [ ' ' . join ( cmd ) for cmd in commands ] ) ) ) #NEWLINE# #UNINDENT# for command in commands : #NEWLINE# #INDENT# output = subprocess . check_output ( command , env = env ) #NEWLINE# sys . stdout . write ( output . decode ( 'utf-8' ) ) #NEWLINE# #UNINDENT# if ( ( not config_data . no_user ) and ( not config_data . noinput ) ) : #NEWLINE# #INDENT# sys . stdout . write ( 'Creating admin user\n' ) #NEWLINE# subprocess . check_call ( ' ' . join ( [ sys . executable , '-W' , 'ignore' , 'manage.py' , 'createsuperuser' ] ) , shell = True )