Opened 8 years ago

Closed 8 years ago

#4191 closed (duplicate)

manage.py sqlindexes generates wrong sql code

Reported by: litnimax Owned by: adrian
Component: Core (Management commands) Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

Pls see example below:

Model:

class SpeedDial(models.Model):

    account = models.ForeignKey(VoipAccount, editable=False)
    sequence = models.CharField(maxlength=1)
    number = models.CharField(maxlength=20)

    def __str__(self):
        return '%s' % self.sequence

    class Admin:
        list_display = ('sequence', 'number')
        list_display_links = ('sequence', 'number')

    class Meta:
        ordering = ('sequence', )
        unique_together = (('sequence','account'),)        
max@explorer ~/Development/public/dtl/r_manager/trunk/rmanager $ python manage.py  sqlall pbx
BEGIN;
CREATE TABLE `pbx_speeddial` (
    `id` integer AUTO_INCREMENT NOT NULL PRIMARY KEY,
    `account_id` integer NOT NULL REFERENCES `ENTVOIPACCT` (`ATRACCTID`),
    `sequence` varchar(1) NOT NULL,
    `number` varchar(20) NOT NULL,
    UNIQUE (`sequence`, `account_id`)
);
CREATE INDEX `pbx_speeddial_account_id` ON `pbx_speeddial` (`account_id`);
COMMIT;

But when we issue:

max@explorer ~/Development/public/dtl/r_manager/trunk/rmanager $ python manage.py  sqlindexes pbx
CREATE INDEX `pbx_speeddial_account_id` ON `pbx_speeddial` (`account_id`);

it only generates index for foreign key.

What about uniq index!?

Change History (1)

comment:1 Changed 8 years ago by Litnimax <litnimax@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #4192

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