Skip to content

Commit

Permalink
Merge pull request #218 from Georiviere/fix_extensions
Browse files Browse the repository at this point in the history
Manage properly extensions in migrations
  • Loading branch information
submarcos authored Oct 27, 2023
2 parents 38daa72 + 5733f44 commit 2f260f5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 0 additions & 2 deletions .docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,5 @@ while ! nc -z $POSTGRES_HOST $PGPORT; do
done
echo "PostgreSQL started"

PGPASSWORD="$POSTGRES_PASSWORD" psql -h "$POSTGRES_HOST" -U "$POSTGRES_USER" -p "$POSTGRES_PORT" -d "$POSTGRES_DB" -c 'CREATE EXTENSION POSTGIS_RASTER' && echo "Extension POSTGIS RASTER installed"
PGPASSWORD="$POSTGRES_PASSWORD" psql -h "$POSTGRES_HOST" -U "$POSTGRES_USER" -p "$POSTGRES_PORT" -d "$POSTGRES_DB" -c 'CREATE EXTENSION UNACCENT' && echo "Extension UNACCENT installed"
# exec
exec "$@"
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ RUN apt-get update -qq && apt-get install -y -qq \
libgdk-pixbuf2.0 \
libpango1.0-0 \
libpangocairo-1.0-0 \
libpq5 \
libpq-dev postgresql-client && \
libpq5 \
postgresql-client && \
apt-get install -y -qq --no-install-recommends postgis && \
apt-get clean all && rm -rf /var/lib/apt/lists/* && rm -rf /var/cache/apt/*

Expand Down
9 changes: 9 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ CHANGELOG
1.2.4+dev (xxxx-xx-xx)
-------------------------

**Breaking changes**

- If you use external database (not docker) you must install unaccent postgres extension with a superuser.
You can do it with this command : `CREATE EXTENSION unaccent; on your database. For docker user, this is made by django migration

**Enhancement**

- Unaccent extension is now installed from django migrations for docker user.



1.2.4 (2023-10-09)
Expand Down
14 changes: 14 additions & 0 deletions georiviere/main/migrations/0013_auto_20231027_1116.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 3.1.14 on 2023-10-27 11:16

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('main', '0012_generate_distancetosource'),
]

operations = [
migrations.RunSQL('CREATE EXTENSION IF NOT EXISTS unaccent;')
]
2 changes: 1 addition & 1 deletion install/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Requirements
* You need docker installed. Docker-compose is recommended in the configuration below.
See `Docker <https://docs.docker.com/engine/install/>`_ and `Docker compose <https://docs.docker.com/compose/install/>`_ install documentations.

* **Optional** : if you want to use external database, prepare a postgresql 10+ postgis2.5+ database with postgis and postgis_raster enabled, and a dedicated user.
* **Optional** : if you want to use external database, prepare a postgresql 10+ postgis2.5+ database with postgis, postgis_raster and unaccent enabled, and a dedicated user.

You can use external database by commenting postgres container and volume references in docker-compose.yml, and set variables :
* POSTGRES_HOST
Expand Down

0 comments on commit 2f260f5

Please sign in to comment.