Fix #663: Do not try to create unaccent extension if it's already present
This commit is contained in:
parent
e44b9e0418
commit
079c66625e
|
@ -3,8 +3,20 @@ from django.db import migrations
|
||||||
from django.contrib.postgres.operations import UnaccentExtension
|
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):
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
dependencies = []
|
dependencies = []
|
||||||
|
|
||||||
operations = [UnaccentExtension()]
|
operations = [CustomUnaccentExtension()]
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Do not try to create unaccent extension if it's already present (#663)
|
Loading…
Reference in New Issue