Skip to content

Infinidat/infi.django_postgresql_migrations

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Overview

This project provides custom Django migration operations for taking advantage of PostgreSQL-specific features. It supports Django 1.7 and later.

Usage

The custom migration operations can be used by creating an empty migration and then filling the operations list. For example:

from django.db import migrations
from infi.django_postgresql_migrations.operations import CreateCompactIndex

class Migration(migrations.Migration):

    dependencies = [
        ('sample_app', '0001_initial'),
    ]

    operations = [
        CreateCompactIndex('SampleModel', 'sample_field'),
    ]

CreateCompactIndex

An operation that creates a BTree GIN index. This kind of index is useful when the column contains many repeating values, since it results in a much smaller index size relative to a regular BTree index.

The constructor expects the model name, the field name, and an optional index name.

CreateCompactIndex('SampleModel', 'sample_field')

It is possible to create a partial index by supplying a WHERE clause:

CreateCompactIndex('SampleModel', 'sample_field', where='sample_field IS NOT NULL')

CreateTrigramIndex

An operation that creates a trigram index. This kind of index is useful for substring matching and fuzzy searches.

The constructor expects the model name, the field name, and an optional index name.

CreateTrigramIndex('SampleModel', 'sample_field')

It is possible to create a partial index by supplying a WHERE clause:

CreateTrigramIndex('SampleModel', 'sample_field', where='sample_field IS NOT NULL')

SetStatistics

An operation that sets the statistics target on a column. This controls how much information about the column's values will be available for the query planner.

The constructor expects the model name, the field name, and an optional statistics target (defaults to 1000).

SetStatistics('SampleModel', 'sample_field', target=500)

Building the Project

Run the following commands:

easy_install -U infi.projector
projector devenv build --use-isolated-python

To run the tests use:

easy_install -U supportal.fabric_contrib

OSX:
    fab -f src/tests/sample_project/fabfile.py -H localhost osx
Unbuntu
    fab -f src/tests/sample_project/fabfile.py -H localhost ubuntu

bin/python src/tests/sample_project/manage.py test tests.sample_project

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages