저는 '프로그래밍 피닉스'라는 책을 사용하여 Phoenix를 배우고 있습니다. 첫 번째 프로젝트는 포스트그레스 DB를 생성하고 이것이 우리의 마이그레이션입니다. 내 스키마에서 타임 스탬프에 대한 경고를 제거 할 수 없습니다.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 스키마의 '타임 스탬프'표현은 어떻게 되나요?
정말 고마워요! 내 Google 검색이 도움이되지 않아서 무슨 일이 일어나고 있는지 알면 좋습니다. – smkarber