Merge branch 'master' of github.com:discourse/discourse_docker
[discourse_docker.git] / templates / postgres.9.2.template.yml
index e0d471a093b6c6ea1945d4114213ebf5df1ed72a..b7168778772821947722bd9ed089460d88161cca 100644 (file)
@@ -1,36 +1,11 @@
 hooks:
-  after_cron:
-    - file:
-       path: /var/lib/postgresql/take-database-backup
-       chown: postgres:postgres
-       chmod: "+x"
-       contents: |
-          #!/bin/bash
-          ID=db-$(date +%F_%T)
-          FILENAME=/shared/postgres_backup/$ID.tar.gz
-          pg_basebackup --format=tar --pgdata=- --xlog --gzip --label=$ID > $FILENAME
-          echo $FILENAME
-
-    - file:
-       path: /var/spool/cron/crontabs/postgres
-       contents: |
-          # m h  dom mon dow   command
-          #MAILTO=?
-          0 */4 * * * /var/lib/postgresql/take-database-backup
-
   before_code:
-    - replace:
-       filename: /etc/service/sidekiq/run
-       from: "# postgres"
-       to: sv start postgres || exit 1
     - replace:
        filename: /etc/service/unicorn/run
        from: "# postgres"
        to: sv start postgres || exit 1
 
 run:
-  # temporary
-  - exec: apt-get install -y socat
   - exec: mkdir -p /shared/postgres_run
   - exec: chown postgres:postgres /shared/postgres_run
   - exec: chmod 775 /shared/postgres_run
@@ -111,6 +86,11 @@ run:
   - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "alter schema public owner to discourse;"'
   - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists hstore;"'
   - exec: /bin/bash -c 'sudo -u postgres psql discourse <<< "create extension if not exists pg_trgm;"'
+  - exec:
+      stdin: |
+        update pg_database set encoding = pg_char_to_encoding('UTF8') where datname = 'discourse' AND encoding = pg_encoding_to_char('SQL_ASCII');
+      cmd: sudo -u postgres psql discourse
+      raise_on_fail: false
 
   - exec:
       hook: postgres