Opened 7 months ago

Closed 7 months ago

#33831 closed Uncategorized (invalid)

How can I create model without primary_key

Reported by: 007 Owned by: nobody
Component: Database layer (models, ORM) Version: 4.0
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have two models:

class Info(models.Model):
    name = models.CharField(verbose_name='name', max_length=128)
    
    class Meta:
        verbose_name = verbose_name_plural = "name"
    
    
class Version(models.Model):
    id = None
    info = models.ForeignKey(Info, on_delete=models.DO_NOTHING, db_constraint=False)
    version = models.CharField(verbose_name='version number', max_length=128)
    
    class Meta:
        unique_together = ('version', 'info')
        verbose_name = verbose_name_plural = "name"

I want to add mysql PARTITION to version.
PARTITION KEY must be included by all unique indexes.
so I want to remove id like

CREATE TABLE `version` (
  `version` varchar(128) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
  `package_id` bigint NOT NULL,
  UNIQUE KEY `version_version_package_id_fc0eb1b8_uniq` (`version`,`package_id`),
  KEY `version_package_id_2d2bab67` (`package_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci
/*!50100 PARTITION BY KEY (package_id)
PARTITIONS 32 */

How can I modify models to meet my needs

Change History (1)

comment:1 Changed 7 months ago by Mariusz Felisiak

Resolution: invalid
Status: newclosed

Please don't use Trac as a support channel. Closing per TicketClosingReasons/UseSupportChannels.

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