File: partition.py

package info (click to toggle)
python-django-postgres-extra 2.0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,096 kB
  • sloc: python: 9,057; makefile: 17; sh: 7; sql: 1
file content (32 lines) | stat: -rw-r--r-- 948 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from django.db.migrations.operations.base import Operation


class PostgresPartitionOperation(Operation):
    def __init__(self, model_name: str, name: str) -> None:
        """Initializes new instance of :see:AddDefaultPartition.

        Arguments:
            model_name:
                The name of the :see:PartitionedPostgresModel.

            name:
                The name to give to the new partition table.
        """

        self.model_name = model_name
        self.model_name_lower = model_name.lower()
        self.name = name

    def deconstruct(self):
        kwargs = {"model_name": self.model_name, "name": self.name}
        return (self.__class__.__qualname__, [], kwargs)

    def state_forwards(self, *args, **kwargs):
        pass

    def state_backwards(self, *args, **kwargs):
        pass

    def reduce(self, *args, **kwargs):
        # PartitionOperation doesn't break migrations optimizations
        return True