Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/peopledoc/django-json-dbindex
Describe your database index in json files into your apps
https://github.com/peopledoc/django-json-dbindex
approved-public ghec-mig-migrated
Last synced: 17 days ago
JSON representation
Describe your database index in json files into your apps
- Host: GitHub
- URL: https://github.com/peopledoc/django-json-dbindex
- Owner: peopledoc
- License: other
- Created: 2014-09-29T08:00:23.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-09-19T07:46:33.000Z (over 8 years ago)
- Last Synced: 2024-04-16T06:52:49.079Z (9 months ago)
- Topics: approved-public, ghec-mig-migrated
- Language: Python
- Size: 79.1 KB
- Stars: 3
- Watchers: 18
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG
- Contributing: CONTRIBUTING.rst
- License: LICENSE
Awesome Lists containing this project
README
[![Documentation Status](https://readthedocs.org/projects/django-json-dbindex/badge/?version=latest)](https://readthedocs.org/projects/django-json-dbindex/?badge=latest)
[![Build Status](https://travis-ci.org/novafloss/django-json-dbindex.svg)](https://travis-ci.org/novafloss/django-json-dbindex)
[![Coverage Status](https://coveralls.io/repos/novafloss/django-json-dbindex/badge.svg)](https://coveralls.io/r/novafloss/django-json-dbindex)**Project not maintained**, this project was created at PeopleDoc to
be used between a short time as a transition tool, it is not used
anymore and so not maintain.===================
django-json-dbindex
===================Describe your database indexes in json files into your apps directory.
Detailed documentation is in the "docs" directory.
Requirements
------------You'll need the ``psycopg2`` package. You may want to install it via your system
packages, but if you're working on a default virtualenv (no-site-packages),
you'll have to install ``postgresql-server-dev-*``. Especially if you want to
test the application via tox.Quick start
-----------1. Add "json_dbindex" to your INSTALLED_APPS setting like this::
INSTALLED_APPS = (
...
'json_dbindex',
)2. Run `python manage.py list_jsdbindex` to list all defined indexes.
Management commands
-------------------* list_jsdbindex
* create_jsdbindex
* drop_jsdbindex
* check_jsdbindexCreate indexes
--------------Create a file in you app directory called `dbindex_create.json` with
following contents```javascript
[{"name": "django_site_composite_idx",
"table": "django_site",
"columns": ["domain","name"],
"predicat": "id > 1000",
"unique": true,
"concurrently": false,
"using": "btree",
"database": "default",
"tablespace": "speedssd"}]
```or with an operator class on PostgreSQL for example
```
[{"name": "django_site_composite_idx",
"table": "django_site",
"columns": [{"name": "gist_trgm_ops"],
"using": "GIST",
"extension": "pg_trgm"}]
```Only fields, **name**, **table** and **columns** are mandatory.
```shell
$ python manage.py create_jsdbindex
```The **concurrently** option is set by default to *true*, do you really
want your index to be created without this option ?Trying to create an existing index will not generate an error, only a
logging at level notice will be raised.Drop indexes
------------Create a file in you app directory called `dbindex_drop.json` with
following contents.```javascript
[{"name": "django_site_composite_idx"},
{"name": "django_site_domain_idx"}]
```Only the name is required. In the above example two indexes will be
dropped. Trying to drop a non existing index will not generate an
error, only a logging at level notice will be raised.```shell
$ python manage.py drop_jsdbindex
```Testing the app
---------------You'll need to install tox (globally or, preferrably in a virtualenv).
The python package ``psycopg2`` must be available.
You may want to setup a postgresql server somewhere. Its credentials may live
in the ``/django-json-dbindex/demo/django_json_dbindex_demo/settings_local.py``Example:
```
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'json_dbindex',
'USER': 'postgres',
'PASSWORD': 'postgres',
'HOST': '127.0.0.1',
'PORT': '5432',
}
}
```You'll need to create at least one "json_dbindex" database on your server. Or
name it as you want.Simply run "tox" to execute tests and other builds.