title: Operational Error: no such column: users_userscore.id
body: <p>For my web application, I have two apps, one is <strong>morse_logs</strong>, the main app; second, is the <strong>users</strong> app, which mainly handles the users details and authentication, etc.</p>
  
  <p>At the moment in my <strong>users</strong> app, I have a <strong>UserProfile</strong> model, which has one variable which is <strong>description</strong>, and now I am struggling to add one more variable <strong>score</strong> to user, so that each user will have one score variable/field to store their scores, and the user's score will be updated after certain actions in morse_logs game1.html and morse_logs/views.py (the main app). </p>
  
  <p>I am really not familiar with modelling and create table, columns these sort of stuff...</p>
  
  <p>And when I do migrations, it gives me error like Operaional Error: table "users_userscore" already exists...</p>
  
  <p>I tried deleting the migrations py files, but it didn't work</p>
  
  <p>all my code are on github: <a href="https://github.com/phl6/morse_log" rel="nofollow noreferrer">https://github.com/phl6/morse_log</a></p>
  
  <p><strong><em>So, my question is how can I edit my model file so I can have a score variable/field for each user which this variable can be updated in the morse_logs(main app).</em></strong></p>
  
  <p><strong>users/model.py</strong></p>
  
  <pre><code>from django.db import models
  from django import forms
  from django.contrib.auth.models import User
  from django.db.models.signals import post_save
  
  # Create your models here.
  
  
  class UserProfile(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE, primary_key=True)
      description = models.CharField(max_length=100, default='')
      #score = models.CharField(User, max_length=10, default=0)
  
  
  def create_profile(sender, **kwargs):
      if kwargs['created']:
          user_profile = UserProfile.objects.create(user=kwargs['instance'])
  
      post_save.connect(create_profile, sender=User)
  
  
  class UserScore(models.Model):
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      score = models.IntegerField(default=0, unique=True, null=False, db_index=True)
      date_added = models.DateTimeField(auto_now_add=True)
  
      def __str__(self):
          """Returns a string representation of the model"""
          return self.score
  
  </code></pre>
  
  <p><strong>morse_logs/views.py</strong></p>
  
  <pre><code>
  @login_required()
  def game1(request):
  
      if request.user and not request.user.is_anonymous:
          user = request.user
      #else:
          #Throw some raised exception here as the user is not valid...
  
      """The Game 1 page"""
      val1 = request.GET.get('ans1', '')
      res = "Incorrect"
  
      user_score = UserScore.objects.get_or_create(user=user)
  
      if val1 == 2:
          #user's score declared in model increase 5points
          #display correct and 5 points added to user
          res = "Correct"
          user_score.score += 5
          user_score.save()
      else:
          #user's score declared in model has no point
          #display incorrect and 0 point added to user
          res = "Incorrect"
  
      return render(request, 'morse_logs/game1.html', {'result': res})
  
  </code></pre>