Merge branch '663-skip-unaccent-if-present' into 'develop'

Fix #663: Do not try to create unaccent extension if it's already present

Closes #663

See merge request funkwhale/funkwhale!549
merge-requests/552/head
Eliot Berriot 2019-01-22 10:01:23 +01:00
commit 657c9c6b4f
2 zmienionych plików z 14 dodań i 1 usunięć

Wyświetl plik

@ -3,8 +3,20 @@ from django.db import migrations
from django.contrib.postgres.operations import UnaccentExtension
class CustomUnaccentExtension(UnaccentExtension):
def database_forwards(self, app_label, schema_editor, from_state, to_state):
check_sql = "SELECT 1 FROM pg_extension WHERE extname = 'unaccent'"
with schema_editor.connection.cursor() as cursor:
cursor.execute(check_sql)
result = cursor.fetchall()
if result:
return
return super().database_forwards(app_label, schema_editor, from_state, to_state)
class Migration(migrations.Migration):
dependencies = []
operations = [UnaccentExtension()]
operations = [CustomUnaccentExtension()]

Wyświetl plik

@ -0,0 +1 @@
Do not try to create unaccent extension if it's already present (#663)