You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When i execgo generate ./ent i get the following error:
entc/load: load schema dir: /home/kay/powerlevel/backend/ent/schema/authentication.go:19:276: not enough arguments in call to field.UUID
have (string)
want (string, driver.Valuer)
exit status 1
ent/generate.go:3: running "go": exit status 1
database
-- CreateTable
CREATE TABLE "users" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"email" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"deleted_at" TIMESTAMP(3),
CONSTRAINT "users_pkey" PRIMARY KEY ("id")
);
-- CreateTable
CREATE TABLE "authentication" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"type" TEXT NOT NULL,
"service_id" TEXT NOT NULL,
"session_id" TEXT NOT NULL,
"password" TEXT NOT NULL,
"created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updated_at" TIMESTAMP(3),
"deleted_at" TIMESTAMP(3),
"user_id" UUID NOT NULL,
CONSTRAINT "authentication_pkey" PRIMARY KEY ("id")
);
-- AddForeignKey
ALTER TABLE "authentication" ADD CONSTRAINT "authentication_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "users"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
I exec the following to get the code generated - go run ariga.io/entimport/cmd/entimport -dsn "postgres://root:password@localhost:5432/powerlevel?sslmode=disable"
This is my first time using entgo, am i doing something wrong?
go version go1.18.4 linux/amd64
ariga.io/entimport v0.0.0-20220722070026-e5b57d96ab7c // indirect
entgo.io/ent v0.11.1 // indirect
Just playing around with it, it seems like in ent/schema/authentication.go this field.UUID("user_id").Optional(uuid.UUID{}) should have been field.UUID("user_id", uuid.UUID{}).Optional()? After editing that change and then attempting to generate, it does generate without errors. But it seems like i should not be editing these generated files. Although i dont think this manual change has worked properly to setup the edges. as the following statement brings back no authentication data despite it being the db. users, err := services.EntClient.User.Query().WithAuthentications().All(services.EntContext)
The text was updated successfully, but these errors were encountered:
I'm having an issue generating the schema from my existing postgres database. Ive been followign this post - https://entgo.io/blog/2021/10/11/generating-ent-schemas-from-existing-sql-databases/
When i exec
go generate ./ent
i get the following error:database
I exec the following to get the code generated -
go run ariga.io/entimport/cmd/entimport -dsn "postgres://root:password@localhost:5432/powerlevel?sslmode=disable"
ent/schema/authentication.go
ent/schema/user.go
This is my first time using entgo, am i doing something wrong?
Just playing around with it, it seems like in
ent/schema/authentication.go
thisfield.UUID("user_id").Optional(uuid.UUID{})
should have beenfield.UUID("user_id", uuid.UUID{}).Optional()
? After editing that change and then attempting to generate, it does generate without errors. But it seems like i should not be editing these generated files. Although i dont think this manual change has worked properly to setup the edges. as the following statement brings back no authentication data despite it being the db.users, err := services.EntClient.User.Query().WithAuthentications().All(services.EntContext)
The text was updated successfully, but these errors were encountered: