Created
September 15, 2017 19:23
-
-
Save levlaz/6b7b631abaf7cbd446eb6389bfbb09dd to your computer and use it in GitHub Desktop.
sql
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| - name: postgres | |
| containers: | |
| - source: circleci-docker | |
| image_name: circleci/postgres-script-enhance | |
| version: ${circleci_postgres_script_enhance} | |
| name: postgres | |
| volumes: | |
| - host_path: /data/circle/postgres/9.5/data | |
| container_path: /var/lib/postgresql/data | |
| env_vars: | |
| - name: POSTGRES_USER | |
| static_val: "{{repl ConfigOption \"POSTGRES_USER\" }}" | |
| - name: POSTGRES_PASSWORD | |
| static_val: "{{repl ConfigOption \"POSTGRES_PASSWORD\" }}" | |
| is_excluded_from_support: true | |
| config_files: | |
| - filename: /docker-entrypoint-initdb.d/init-dbs.sh | |
| file_mode: "0777" | |
| contents: | | |
| #! /bin/bash | |
| set -e | |
| create_db() { | |
| db="$@" | |
| echo "Creating DB $db" | |
| if ! `psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -c "SELECT 1 FROM pg_database WHERE datname = '$db'" | grep -q 1`; then | |
| psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" -c "create database $db" | |
| else | |
| echo "DB already exists" | |
| fi | |
| } | |
| create_db vms | |
| create_db conductor_production | |
| create_db contexts_service_production | |
| psql -v --username "$POSTGRES_USER" -c "VACUUM (VERBOSE, FULL)" | |
| psql -v --username "$POSTGRES_USER" -c "VACUUM (VERBOSE, ANALYZE)" | |
| restart: | |
| policy: on-failure | |
| max: 50 | |
| publish_events: | |
| - name: Postgresql 9.4 ready | |
| trigger: port-listen | |
| data: "5432" | |
| subscriptions: | |
| - component: contexts-service-db-migrator | |
| container: circleci/contexts-service-migrator | |
| action: start | |
| - component: workflows-conductor-db-migrator | |
| container: circleci/workflows-conductor-migrator | |
| action: start | |
| ports: | |
| - private_port: "5432" | |
| public_port: "5432" | |
| port_type: tcp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment