PostgresPartitionedModels cannot be used as abstract models
wesleykendall opened this issue · 0 comments
wesleykendall commented
For example:
class PartitionedEvent(PostgresPartitionedModel):
class PartitioningMeta:
method = PostgresPartitioningMethod.RANGE
key = ["pgh_created_at"]
pgh_created_at = models.DateTimeField()
class Meta:
abstract = True
class ConcretePartitionEvent(PartitionedEvent):
pass
When calling manage.py pgmakemigrations
, it will produce a migration with operations that look like this:
operations = [
psqlextra.backend.migrations.operations.create_partitioned_model.PostgresCreatePartitionedModel(
name='ConcretePartitionEvent',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('pgh_created_at', models.DateTimeField()),
],
options={
'abstract': False,
},
partitioning_options={
'method': psqlextra.types.PostgresPartitioningMethod['RANGE'],
'key': [],
},
bases=(psqlextra.models.partitioned.PostgresPartitionedModel,),
managers=[
('objects', psqlextra.manager.manager.PostgresManager()),
],
),
psqlextra.backend.migrations.operations.add_default_partition.PostgresAddDefaultPartition(
model_name='ConcretePartitionEvent',
name='default',
),
]
Notice how "key" is []
. This results in
django.core.exceptions.ImproperlyConfigured: Model 'ConcretePartitionEvent' is not properly configured to be partitioned. Set the `method` and `key` attributes on the `PartitioningMeta` class as a child of 'ConcretePartitionEvent'
When I simply make the parent model a concrete model, everything works as expected.
I couldn't find anything in the docs. Is this expected behavior?
Django=3.2.15
django-postgres-extra=2.0.4