我正在尝试将一个字符串列设置为表的主键,然后从另一个表中引用该主键作为外键。这种做法可行吗? 根据文档:
Laravel assumes every table has a numeric primary key (usually named “id”) and ensures the value of this column is unique for each new row added to the table. Laravel doesn’t really work well unless each table has a numeric primary key. So, for your average Laravel application, please ensure that you define a primary key using the increments() method.
在我的情况下,我不想定义一个
id
列,因为它是无用的。我想要定义的字符串列将作为主键。如果可能的话,我可以得到一个迁移片段示例吗?
id
? - StackOverflowNewbie