Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • go go
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 21
    • Issues 21
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • SRCT
  • gogo
  • Issues
  • #87

Closed
Open
Created Nov 18, 2016 by David Haynes@dhaynes3🙆Owner

Change the PK of the URL model to be the default id

Summary

I made a mistake when writing 2.0 and we need to fix it. Currently, the Primary Key of each URL is it's short URL. This is fine in concept as we want each Go link to be unique (as to prevent conflicting Go links). However in #25 (closed) we want users to edit their links including their short link. When this happens, Django creates an entirely new Go link and does not remove the previous link (Required reading: https://docs.djangoproject.com/en/1.10/ref/models/instances/#how-django-knows-to-update-vs-insert). So, we want to instead go back to using the default Primary Key which is simply an id field. Luckily Django creates this for us if we do not specify a Primary Key on our own.

So in short:

  • remove the current PK
  • find a way for current links to be migrated into this new id PK
  • migrate your database

Currently the PK of a URL is its short url

this is bad because we want to modify the short url in an upcoming feature

we need to have the URL model rely on the Django defualt id that it assigns rows

Resources

  • https://docs.djangoproject.com/en/1.10/ref/models/instances/#the-pk-property
  • https://docs.djangoproject.com/en/1.10/ref/models/instances/#how-django-knows-to-update-vs-insert
  • https://docs.djangoproject.com/en/1.10/ref/models/instances/#how-django-knows-to-update-vs-insert
Assignee
Assign to
Time tracking