Skip to content

Commit

Permalink
Merge pull request #214 from chescales/feature/configure-db-extensions
Browse files Browse the repository at this point in the history
Added the possibility to configure `db_extensions` in the `.aldryn` file
  • Loading branch information
chescales authored Feb 28, 2018
2 parents 9d493dc + 7593042 commit 554019d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion divio_cli/localdev/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def del_rw(action, name, exc):


class DatabaseImportBase(object):
database_extensions = ['hstore', 'postgis']
restore_commands = {
'sql': 'psql -U postgres db < {}',
'binary': (
Expand All @@ -183,6 +182,7 @@ def __init__(self, *args, **kwargs):
self.website_id = utils.get_aldryn_project_settings(self.path)['id']
self.website_slug = utils.get_aldryn_project_settings(self.path)['slug']
self.docker_compose = utils.get_docker_compose_cmd(self.path)
self.database_extensions = self.get_active_db_extensions()
docker_compose_config = utils.DockerComposeConfig(self.docker_compose)
if not docker_compose_config.has_service('db'):
click.secho('No service "db" found in local project', fg='red')
Expand All @@ -202,6 +202,21 @@ def run(self):
self.restore_db()
self.finish()

def get_active_db_extensions(self):
project_settings = utils.get_aldryn_project_settings(self.path)
default_db_extensions = ['hstore', 'postgis']

if 'db_extensions' in project_settings:
if not isinstance(project_settings['db_extensions'], list):
raise click.ClickException(
'{} file contains invalid "db_extensions" value. '
'It should contain a list of extensions, for instance: {}'
.format(settings.ALDRYN_DOT_FILE, default_db_extensions)
)
return project_settings['db_extensions']
else:
return default_db_extensions

def prepare_db_server(self):
utils.start_database_server(self.docker_compose)

Expand Down

0 comments on commit 554019d

Please sign in to comment.