zoo/zoo/zoo_meta/migrations/0002_auto_20161214_1545.py

28 lines
1.0 KiB
Python

# -*- coding: utf-8 -*-
# Generated by Django 1.10.4 on 2016-12-14 15:45
from __future__ import unicode_literals
from django.db import migrations
from django.contrib.postgres.operations import TrigramExtension, UnaccentExtension
class Migration(migrations.Migration):
dependencies = [
('zoo_meta', '0001_initial'),
]
operations = [
TrigramExtension(),
UnaccentExtension(),
migrations.RunSQL([
"CREATE OR REPLACE FUNCTION immutable_unaccent(text) RETURNS varchar AS $$ "
" SELECT unaccent('unaccent',$1::text); $$ LANGUAGE 'sql' IMMUTABLE",
"CREATE OR REPLACE FUNCTION immutable_timestamp(text) RETURNS timestamp AS $$ "
"SELECT $1::timestamp; $$ LANGUAGE sql IMMUTABLE",
"CREATE OR REPLACE FUNCTION immutable_normalize(text) RETURNS varchar AS $$ "
" SELECT regexp_replace(lower(unaccent('unaccent', $1::text)), ' *([''-] *)+', 'x', 'g'); "
"$$ LANGUAGE sql IMMUTABLE",
], []),
]