在我的 Django 应用程序 models.py 中,我最近添加了这个字段。
Class Client
user = models.ForeignKey(User)
我想在 mysql 中将这个字段添加到一个现有表。问题是我不知道处理外键的命令。我要添加此列的表的名称称为 tiptop_clients
。
最佳答案
您可以使用 sqldiff
-命令django-extensions :
Django command that scans all models for the given appnames and compares there database schema with the real database tables.
It indicates how columns in the database are different from the SQL that would be generated by Django. This command is not a database migration tool. Though it might certainly be of help during migrations. It’s purpose is to show the current differences as a way to checking or debugging your models compared to the real database tables and columns.
关于mysql - 想要向现有表添加一个外键列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6569562/