-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into migrate-to-django-filter-v2
- Loading branch information
Showing
7 changed files
with
120 additions
and
28 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# THIS DOCKER COMPOSE FILE IS ONLY PROVIDED AS AN EXAMPLE, IT IS NOT SUITABLE FOR PRODUCTION AS IS. | ||
services: | ||
postgres: | ||
# If you want the data in the database to remain after the container is stopped, | ||
# you should mount a directory into /var/lib/postgresql/data, or use a volume. See the documentation: | ||
# https://github.com/docker-library/docs/blob/master/postgres/README.md#where-to-store-data | ||
image: postgres | ||
environment: | ||
- POSTGRES_USER=mreg | ||
- POSTGRES_DB=mreg | ||
- POSTGRES_PASSWORD=mreg | ||
healthcheck: | ||
test: ["CMD", "pg_isready", "--username=mreg"] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 | ||
start_period: 5s | ||
|
||
# Uncomment this if you want a RabbitMQ server to send events to. See also MQ config in settings.py | ||
# rabbitmq: | ||
# image: rabbitmq | ||
# ports: | ||
# - 5672:5672 | ||
|
||
mreg: | ||
depends_on: | ||
postgres: | ||
condition: service_healthy | ||
#rabbitmq: | ||
# condition: service_started | ||
build: . | ||
ports: | ||
- 8000:8000 | ||
environment: | ||
- MREG_DB_HOST=postgres | ||
- MREG_DB_NAME=mreg | ||
- MREG_DB_USER=mreg | ||
- MREG_DB_PASSWORD=mreg |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/sh | ||
set -e | ||
cd /app | ||
./manage.py create_citext_extension --database template1 | ||
./manage.py test --noinput --failfast |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from django.core.management.base import BaseCommand, CommandError | ||
from django.db import connection | ||
from sys import stdout | ||
from django.conf import settings | ||
from psycopg2 import connect | ||
|
||
class Command(BaseCommand): | ||
help = 'Create the CITEXT extension in the database.' | ||
|
||
def add_arguments(self, parser): | ||
# optional argument | ||
parser.add_argument( | ||
'--database', | ||
type=str, | ||
help='Database name', | ||
) | ||
|
||
def handle(self, *args, **options): | ||
stdout.write("Attempting to create the CITEXT extension in the database...\n") | ||
stdout.flush() | ||
try: | ||
con = connection | ||
if options['database']: | ||
stdout.write(f"Connecting to database {options['database']}\n") | ||
stdout.flush() | ||
con = connect(host=settings.DATABASES['default']['HOST'], | ||
user=settings.DATABASES['default']['USER'], | ||
password=settings.DATABASES['default']['PASSWORD'], | ||
database=options['database']) | ||
with con.cursor() as cursor: | ||
cursor.execute("CREATE EXTENSION IF NOT EXISTS citext") | ||
stdout.write(cursor.statusmessage+"\n") | ||
stdout.flush() | ||
con.commit() | ||
except Exception as e: | ||
stdout.write(e.__str__()) | ||
stdout.flush() | ||
raise CommandError('Failed to create the CITEXT extension in the database.') |