Elixir 你所属的星外星和凤凰1.3已经消失了吗?
今天,我在我的机器上安装了phoenix 1.3,以使用以下命令测试新功能:Elixir 你所属的星外星和凤凰1.3已经消失了吗?,elixir,phoenix-framework,ecto,Elixir,Phoenix Framework,Ecto,今天,我在我的机器上安装了phoenix 1.3,以使用以下命令测试新功能: mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez 并创建了新的凤凰项目 mix phx.new new_version 然后,我生成了一个博客上下文(或边界),其中包含两个模型(帖子和评论),如下所示: cd new_version mix phx.gen.html Blog Post pos
mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
并创建了新的凤凰项目
mix phx.new new_version
然后,我生成了一个博客上下文(或边界),其中包含两个模型(帖子和评论),如下所示:
cd new_version
mix phx.gen.html Blog Post posts title body:text
mix phx.gen.html Blog Comment comments title body:text comment_post_id:references:blog_posts
schema "comments" do
field :title, :string
field :body, :string
belongs_to :post, OldVersion.Post
timestamps()
end
之后,我查看了注释模型文件,发现生成的模式与phoenix 1.2中的不同
phoenix 1.3注释模式:
schema "blog_comments" do
field :body, :string
field :title, :string
field :comment_post_id, :id
timestamps()
end
而在phoenix 1.2中,注释生成的模式如下所示:
cd new_version
mix phx.gen.html Blog Post posts title body:text
mix phx.gen.html Blog Comment comments title body:text comment_post_id:references:blog_posts
schema "comments" do
field :title, :string
field :body, :string
belongs_to :post, OldVersion.Post
timestamps()
end
您可以看到缺少属于部分架构的
所以问题是,我们应该如何定义新的Ecto和Phoenix 1.3的模型关系(或模式关联)?很多到很多,有很多,有一个,属于所有人吗?
我这样问是因为我在任何地方都找不到这种新的模式格式,所以如果它在文档中,请告诉我
我还注意到phoenix生成的迁移不是到/priv/repo目录,而是到/test/new_version/priv/repo目录。这是所需的行为还是我应该更改配置?在我看来似乎是生成器中的一个错误。这仍然可以从中获得。您必须将
字段:comment\u post\u id,:id
替换为归属于:comment\u post,post
不确定这是否是错误,或者更确切地说,它已经讨论过了,并且决定不生成归属于
,因此这应该由开发人员手动处理: