首页 > 解决方案 > 在创建表中添加对另一个表的引用

问题描述

如何在我的 sql 脚本中添加对另一个表的引用?

在 Ecto.Schema 中,我需要将其添加到 Create Table SQL 脚本中

has_one(:contact, Contact,
  foreign_key: :user_id,
  references: :id,
  where: [friend: true]
)

我的 sql 脚本看起来像

create table somemodule.table
 user_id INT,
 ...

标签: elixirecto

解决方案


推荐阅读