F
F
FulTupFul2018-08-31 20:43:32
PostgreSQL
FulTupFul, 2018-08-31 20:43:32

Partitioning tables in django?

class Ground(models.Model):
    cadastral_number = models.CharField(primary_key=True, max_length=24)
    area = models.FloatField(null=True)   # Если строительство незавершенно то значение 0
    district = models.CharField(max_length=120, blank=True, null=True)
    region = models.IntegerField( blank=True, null=True)          # dRegionsRF

And I implemented partitioning using table inheritance by region. Created rules, and it seems everything works. But when writing with related objects, an
insert or update on table "ground" violates foreign key constraint "classifier_ground_id_ff3a6d69_fk"
DETAIL: Key (ground_id)=(40:00:000000:196) is not present in table "ground" error occurs.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Tikhonov, 2018-09-02
@FulTupFul

https://www.postgresql.org/docs/10/static/ddl-part...
Looks like FKs on a partitioned table are not supported. You can manually drop the constraint and carefully monitor the integrity of the database.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question