Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make an actual foreign key between docs versions and core versions

This was originally not done because we had a lot of old legacy data
that didn't have entries in both tables. This is no longer the case,
and the docloads script already enforced that it couldn't happen again.

Requires SQL:
ALTER TABLE core_version ADD CONSTRAINT version_unique_tree UNIQUE(tree);
ALTER TABLE docs ADD CONSTRAINT docs_version_fkey FOREIGN KEY (version) REFERENCES core_version(tree);
  • Loading branch information...
commit 8e458731cba7658bec1957455dc6db753e4bd711 1 parent beaa87f
@mhagander mhagander authored
Showing with 4 additions and 4 deletions.
  1. +1 −1  pgweb/core/
  2. +3 −3 pgweb/docs/
2  pgweb/core/
@@ -6,7 +6,7 @@
from datetime import datetime
class Version(PgModel, models.Model):
- tree = models.DecimalField(max_digits=3, decimal_places=1, null=False, blank=False)
+ tree = models.DecimalField(max_digits=3, decimal_places=1, null=False, blank=False, unique=True)
latestminor = models.IntegerField(null=False, blank=False, default=0, help_text="For beta versions, latestminor means latest beta number. For other releases, it's the latest minor release number in the tree.")
reldate = models.DateField(null=False, blank=False)
relnotes = models.CharField(max_length=32, null=False, blank=False)
6 pgweb/docs/
@@ -8,16 +8,16 @@
class DocPage(models.Model):
id = models.AutoField(null=False, primary_key=True)
file = models.CharField(max_length=64, null=False, blank=False)
- version = models.DecimalField(max_digits=3, decimal_places=1, null=False)
+ version = models.ForeignKey(Version, null=False, blank=False, db_column='version', to_field='tree')
title = models.CharField(max_length=256, null=True, blank=True)
content = models.TextField(null=True, blank=True)
def display_version(self):
"""Version as used for displaying and in URLs"""
- if self.version == 0:
+ if self.version.tree == 0:
return 'devel'
- return str(self.version)
+ return str(self.version.tree)
class Meta:
db_table = 'docs'
Please sign in to comment.
Something went wrong with that request. Please try again.