3
我正在使用“Programming Phoenix”一书学习Phoenix。第一个项目创建了一个postgres数据库,这是我们的迁移。我无法摆脱架构中时间戳的警告。Phoenix/Elixir - 时间戳不存在,扩展为时间戳()
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, :string, virtual: true
field :password_hash, :string
timestamps
end
end
现在我跑迁移,其次是mix phoenix.server
。如果我到timestamps()
它不抱怨,再架构改变timestamps
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
,但书从未展示模型的架构是什么样的运行迁移后:
我得到这样的警告。这应该是正确的,还是有其他东西可以解决这个问题? Ecto/Phoenix模式中的'时间戳'表示应该是什么样子?
非常感谢!很高兴知道发生了什么,因为我的谷歌搜索没有帮助。 – smkarber