Skip to content

Commit 5b1da84

Browse files
committed
Update several auto-created id fields/sequences to be BIGINT.
fixes #2080.
1 parent 07d0ef9 commit 5b1da84

2 files changed

Lines changed: 25 additions & 1 deletion

File tree

CHANGES/2080.bugfix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Altered several id-fields and their related sequences.
2+
3+
INTEGER AutoField sequences can "run out" on large/old instances, update to BIGINT.

pulp_container/app/__init__.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
from pulpcore.plugin import PulpPluginAppConfig
2+
from django.db import connection
3+
from django.db.models.signals import post_migrate
24

3-
5+
update_sequences_to_bigint = """
6+
ALTER TABLE container_blobmanifest ALTER COLUMN id TYPE bigint;
7+
ALTER TABLE container_manifestlistmanifest ALTER COLUMN id TYPE bigint;
8+
ALTER TABLE container_containerpushrepository_pending_blobs ALTER COLUMN id TYPE bigint;
9+
ALTER TABLE container_containerpushrepository_pending_manifests ALTER COLUMN id TYPE bigint;
10+
ALTER TABLE container_containerrepository_pending_manifests ALTER COLUMN id TYPE bigint;
11+
ALTER TABLE container_containerrepository_pending_blobs ALTER COLUMN id TYPE bigint;
12+
ALTER SEQUENCE container_blobmanifest_id_seq AS BIGINT;
13+
ALTER SEQUENCE container_manifestlistmanifest_id_seq AS BIGINT;
14+
ALTER SEQUENCE container_containerpushrepository_pending_blobs_id_seq AS BIGINT;
15+
ALTER SEQUENCE container_containerpushrepository_pending_manifests_id_seq AS BIGINT;
16+
ALTER SEQUENCE container_containerrepository_pending_blobs_id_seq AS BIGINT;
17+
ALTER SEQUENCE container_containerrepository_pending_manifests_id_seq AS BIGINT;
18+
"""
419
class PulpContainerPluginAppConfig(PulpPluginAppConfig):
520
"""Entry point for the container plugin."""
621

@@ -10,6 +25,12 @@ class PulpContainerPluginAppConfig(PulpPluginAppConfig):
1025
python_package_name = "pulp-container"
1126
domain_compatible = True
1227

28+
@staticmethod
29+
def update_sequences(sender, **kwargs):
30+
cursor = connection.cursor()
31+
cursor.execute(update_sequences_to_bigint)
32+
1333
def ready(self):
1434
super().ready()
1535
from . import checks
36+
post_migrate.connect(PulpContainerPluginAppConfig.update_sequences, sender=self)

0 commit comments

Comments
 (0)