postgresql – Phoenix / Elixir – 时间戳不存在,扩展到时间戳(
发布时间:2020-12-13 15:58:55 所属栏目:百科 来源:网络整理
导读:我正在使用“编程凤凰”这本书学习凤凰.第一个项目创建了一个postgres数据库,这是我们的迁移.我无法摆脱模式中时间戳的警告. defmodule Rumbl.Repo.Migrations.CreateUser do use Ecto.Migration def change do create table(:users) do add :name,:string a
我正在使用“编程凤凰”这本书学习凤凰.第一个项目创建了一个postgres数据库,这是我们的迁移.我无法摆脱模式中时间戳的警告.
defmodule Rumbl.Repo.Migrations.CreateUser do use Ecto.Migration def change do create table(:users) do add :name,:string add :username,:string,null: false add :password_hash,:string timestamps end create unique_index(:users,[:username]) end end 那么我们对应这个迁移的模型是: defmodule Rumbl.User do use Rumbl.Web,:model schema "users" do field :name,:string field :username,:string field :password,virtual: true field :password_hash,:string timestamps end end 现在我运行迁移,然后混合phoenix.server. 我收到这个警告: warning: variable "timestamps" does not exist and is being expanded to "timestamps()",please use parentheses to remove the ambiguity or change the variable name web/models/user.ex:10 如果我将模式中的时间戳更改为timestamps(),它就不会再抱怨了,但本书从未显示运行迁移后模型的模式.这应该是正确的,还是有其他东西可以解决这个问题? Ecto / Phoenix模式中的’timestamps’表示应该是什么样的? 解决方法
Elixir 1.4在调用带有0个参数但没有括号的导入或本地定义函数时添加了一个警告,因为当你有一个与函数同名的局部变量并且你写的变量名没有括号时它应该是什么意思不明确.
Source 这本书可能尚未针对Elixir 1.4进行更新. Phoenix发电机已更新,添加括号in June 2016. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |