#34843 closed New feature (wontfix)

Feature request: Support postgres table storage options

Reported by: Anton Shutik Owned by: nobody
Component: Migrations Version: 3.2
Severity: Normal Keywords: postgres, autovacuum, storage options, django migrations
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Anton Shutik)

There is a list of storage options (https://www.postgresql.org/docs/current/sql-createtable.html#SQL-CREATETABLE-STORAGE-PARAMETERS) that can be applied when creating a table in postgres database. So, since django manages database schema, it would be nice to extend it to support these storage options.

It might look like:

class MyModel(models.Model):
  
    #  fields go here
  
    class Meta:
      storage_options = {
          "autovacuum_vacuum_scale_factor": 0.01,
          "autovacuum_vacuum_threshold": 1000
      }

and that would produce migration which eventually will run sql like this:

CREATE/ALTER TABLE mymodel WITH (autovacuum_vacuum_scale_factor = 0.01, autovacuum_vacuum_threshold = 1000);

For now it could be done with RunSQL(sql='CREATE/ALTER TABLE .... WITH (...);') migration, but it would be better to have the settings on the model class itself for better visibility and managed by django.

What do you think ?

Change History (4)

comment:1 by Anton Shutik, 14 months ago

Description: modified (diff)

comment:2 by Anton Shutik, 14 months ago

Description: modified (diff)

comment:3 by Anton Shutik, 14 months ago

Description: modified (diff)

comment:4 by David Sanders, 14 months ago

Resolution: wontfix
Status: newclosed

Hi Anton,

Thanks for the idea, though all feature requests should be discussed on the Django forum first where it'll reach a wider audience: https://code.djangoproject.com/wiki/DevelopersMailingList

Having said that, it may be unlikely to be accepted since developers can add their own migration to set these parameters after table creation. Additionally it is likely to be considered outside the scope of what Django is responsible for.

Thanks!

Note: See TracTickets for help on using tickets.
Back to Top