Opened 6 years ago

Closed 6 years ago

#24051 closed Bug (fixed)

Tables are not created in specified tablespace when DEFAULT_TABLESPACE is specified

Reported by: douglasjreynolds Owned by: nobody
Component: Database layer (models, ORM) Version: 1.7
Severity: Release blocker Keywords: Tablespace model
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When DEFAULT_TABLESPACE is specified in the project settings.py using database backend, django.db.backends.postgresql_psycopg2, the DDL does not include the 'TABLESPACE' keyword, and the table is created in the default PostgreSQL tablespace.

This does not affect the INDEX tablespace. The INDEXes are always created in the correct tablespace (both with just DEFAULT_TABLESPACE and/or DEFAULT_INDEX_TABLESPACE).

The patch is based off of Django 1.7.1.
I have attached a patch to correct this issue. It fixed the issue for me.

Attachments (1)

django_tablespace_patch.diff (692 bytes) - added by douglasjreynolds 6 years ago.
Tablespace patch of django.db.backends.schema

Download all attachments as: .zip

Change History (7)

Changed 6 years ago by douglasjreynolds

Tablespace patch of django.db.backends.schema

comment:1 Changed 6 years ago by Tim Graham

Needs tests: set
Severity: NormalRelease blocker
Triage Stage: UnreviewedAccepted

Could you add a test and release notes for 1.7.2? If you are able to send a pull request on GitHub, that will ease testing and review, thanks.

comment:2 in reply to:  1 ; Changed 6 years ago by douglasjreynolds

Replying to timgraham:

Could you add a test and release notes for 1.7.2? If you are able to send a pull request on GitHub, that will ease testing and review, thanks.

I am attempting to get a pull request ready for you on GitHub. I am not real familiar with GitHub, so bear with me.

comment:3 in reply to:  2 Changed 6 years ago by douglasjreynolds

Replying to douglasjreynolds:

Replying to timgraham:

Could you add a test and release notes for 1.7.2? If you are able to send a pull request on GitHub, that will ease testing and review, thanks.

I am attempting to get a pull request ready for you on GitHub. I am not real familiar with GitHub, so bear with me.

I have put the code, tests, and documentation in pull request https://github.com/django/django/pull/3796

After looking at the master branch, I saw that code had been included to correct this issue. It looks like this was caused by the new makemigration code in 1.7.

Let me know if you need anything else!

comment:4 Changed 6 years ago by Claude Paroz

Needs tests: unset

Alternate patch without creating new tests: https://github.com/django/django/pull/3798

comment:5 Changed 6 years ago by Tim Graham

Triage Stage: AcceptedReady for checkin

comment:6 Changed 6 years ago by Claude Paroz <claude@…>

Resolution: fixed
Status: newclosed

In 322560489b2d2f873c7b8bd7799efd7cf80fb28b:

[1.7.x] Fixed #24051 -- Made schema infrastructure honor tablespaces

Partial backport of 30cbd5d36. Thanks Douglas J. Reynolds for the
report and initial patch.

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