Skip to content
This repository was archived by the owner on Nov 25, 2021. It is now read-only.

Commit acb86c9

Browse files
virusdefendermonouno
authored andcommitted
Update some document
1 parent b52804e commit acb86c9

File tree

4 files changed

+36
-20
lines changed

4 files changed

+36
-20
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
*.egg-info
22
dist/
33
build/
4-
docs/build
4+
docs/_build
55
docs/source/.doctrees/
66
__pycache__/
77
.cache

docs/source/decorators.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Decorators
33

44
Now the decorator must be used on a non-abstract model class that has not yet built a table in the database.
55
If you must use the decorator on a model class that has previously performed a migrate operation, you need
6-
to back up the model's data, then delete the table, and then import the data after you have created a
6+
to back up the model's data, then drop the table, and then import the data after you have created a
77
partitioned table.
88

99
.. py:currentmodule:: pg_timepart.manager
@@ -14,5 +14,5 @@ partitioned table.
1414
Post-Decoration
1515
---------------
1616

17-
You can run ``makemigration`` and ``migrate`` commands to create and apply new migrations.
17+
You can run ``makemigrations`` and ``migrate`` commands to create and apply new migrations.
1818
Once the table has been created, it is not possible to turn a regular table into a partitioned table or vice versa.

docs/source/design.rst

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,39 @@ Conflict Avoidance
1717
------------------
1818

1919
It is important to note that if the field has the ``primary_key`` or ``unique`` attribute set, but it is not a partitioned field, we will ignore the
20-
`PRIMARY KEY` or `UNIQUE` declarations for that field in the SQL statement generated by Django. Django itself ignores the ``db_index``
20+
``PRIMARY KEY`` or ``UNIQUE`` declarations for that field in the SQL statement generated by Django. Django itself ignores the ``db_index``
2121
attribute of such fields, so you cannot use this method to create field indexes.
2222

23+
A workaround is to add a ``indexes`` declaration in your model, for example
24+
25+
.. code-block:: python
26+
27+
@TimeRangePartitioningSupport("timestamp")
28+
class DataTable(models.Model):
29+
id = models.BigIntegerField(primary_key=True, serialize=False)
30+
timestamp = models.DateTimeField()
31+
data = models.TextField()
32+
33+
class Meta:
34+
# If you do not add this line, id field will not have a index
35+
indexes = (models.Index(fields=("id", )), )
36+
2337
Tablespace
2438
----------
2539

26-
django-partitioning will silently set the tablespace of all local partitioned indexes under one partition to be consistent with
40+
``pg_timepart`` will silently set the tablespace of all local partitioned indexes under one partition to be consistent with
2741
the partition.
2842

2943
Partition Information
3044
---------------------
3145

32-
django-partitioning persists partition configuration and state information with `PartitionConfig` and `PartitionLog`.
33-
The problem with this is that once this information is inconsistent with the actual situation, django-partitioning
34-
will not work properly, and you can only fix it manually.
46+
``pg_timepart`` saves partition configuration and state information in ``PartitionConfig`` and ``PartitionLog``.
47+
The problem with this is that once this information is inconsistent with the actual situation, ``pg_timepart``
48+
will not work properly, so you can only fix it manually.
3549

3650
Management
3751
----------
3852

3953
You can use ``Model.partitioning.create_partition`` and ``Model.partitioning.detach_partition`` to automatically create and
40-
archive partitions. In addition setting `default_detach_tablespace` and `default_attach_tablespace`, you can also use the
54+
archive partitions. In addition setting ``default_detach_tablespace`` and ``default_attach_tablespace``, you can also use the
4155
``set_tablespace`` method of the PartitionLog object to move the partition. See :doc:`api` for details.

docs/source/installation.rst

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
Installation
22
============
33

4-
GitHub
5-
------
4+
PyPI
5+
----
66

77
.. code-block:: bash
88
9-
$ pip install git+https://github.com/chaitin/django-pg-timepart.git@master
9+
$ pip install django-pg-timepart
1010
11-
PyPI
12-
----
11+
Or you can install from GitHub
1312

1413
.. code-block:: bash
1514
16-
$ pip install django-pg-timepart
15+
$ pip install git+https://github.com/chaitin/django-pg-timepart.git@master
1716
18-
Django
19-
------
17+
Integrate with Django
18+
---------------------
2019

21-
settings.py (Important - Please note 'django-partitioning' is loaded earlier than the app that depends on it)::
20+
Add ``pg_timepart`` to ``INSTALLED_APPS`` in settings.py.
21+
22+
Important - Please note 'pg_timepart' should be loaded earlier than other apps that depend on it::
2223

2324
INSTALLED_APPS = [
2425
'pg_timepart',
@@ -27,12 +28,13 @@ settings.py (Important - Please note 'django-partitioning' is loaded earlier tha
2728

2829
PARTITION_TIMEZONE = "Asia/Shanghai"
2930

30-
You can specify the time zone referenced by the time range partitioned table via `PARTITION_TIMEZONE`,
31-
and if it is not specified, get the value of `TIME_ZONE`.
31+
You can specify the time zone referenced by the time range partitioned table via ``PARTITION_TIMEZONE``,
32+
and if it is not specified, ``TIME_ZONE`` value is used.
3233

3334
Post-Installation
3435
-----------------
3536

3637
In your Django root execute the command below to create 'pg_timepart' database tables::
3738

3839
./manage.py migrate pg_timepart
40+

0 commit comments

Comments
 (0)