Пример #1
0
def make_extension_config(extension_module_name):
  config = Config(get_base_config_file())
  # Record the current `extension_module_name` in the config to make it
  #   available to `ScriptDirectory` and `EnvironmentContext`
  config.set_main_option('extension_module_name', extension_module_name)
  module = get_extension_module(extension_module_name)
  # If the extension module contains a `migrations/env.py`, then use that,
  #   otherwise use `ggrc/migrations/env.py`
  module_script_location = get_extension_migrations_dir(module)
  if os.path.exists(os.path.join(module_script_location, 'env.py')):
    script_location = module_script_location
  else:
    script_location = get_base_migrations_dir()
  config.set_main_option('script_location', script_location)
  # Specify location of `versions` directory to be independent of `env.py`
  module_versions_location = os.path.join(module_script_location, 'versions')
  config.set_main_option('versions_location', module_versions_location)
  return config
Пример #2
0
 def __init__(self, extension_module_name):
   self.extension_module = get_extension_module(extension_module_name)
   self.config = make_extension_config(self.extension_module)
   self.script_dir = ScriptDirectory.from_config(self.config)