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