Migrate django app in tutor dev

Hi im new to tutor openedx. Im trying to create new feature like add more user detail when register to user so Im following this article

in my model.py it look like this

class UserMoreDetail(models.Model):
    """
    UserMoreDetail model for storing additional user details.
    """

    address = models.CharField(max_length=255)
    user = models.ForeignKey(User, on_delete=models.CASCADE)

then i use python manage.py makemigration then in tutor_dev-lms-1 run python manage.py migrate repo)name

it would freeze like this

Operations to perform:
  Apply all migrations: repo_name
Running migrations:
  Applying repo_name.0002_usermoredetail_user...

so i access sql bash and run show full processlist and saw state Waiting for table metadata lock

so i try by commented out the field user and i work fine so any other i can add relation to user?

Hi @PP_Ra, welcome to the forum!!

Looks like there is a problem in the connection with the DB, which shouldn’t happen.
I suggest you makemigrations with --dry-run and -- verbosity 3 first to get more details on the process.

Thankyou for your reply! I just came back to this work them try --dry-run --verbosity 3 and see nothing wrong so i just retry the process makemigration and migrate and this time it work! maybe this happen because last time I tried to use python mysql.connector to access my table then did not commit so it might be lock because of that.

1 Like