Skip to content

Foreign key and id type does not match when use change Id type #455

Description

@nakaji-dayo

I want to use "Change table Id field type"

It works with postgresql.
But relation column type is always Int, so error has occurred at creating Foreign Key.

I had try followings.

  • model
User
    Id    Day default=CURRENT_DATE
    ident Text
    password Text Maybe
    UniqueUser ident
    deriving Typeable
Email
    email Text
    user UserId Maybe
    verkey Text Maybe
    UniqueEmail email
  • log: create table
Migrating: CREATe TABLE "user"("id" DATE PRIMARY KEY UNIQUE DEFAULT CURRENT_DATE,"ident" VARCHAR NOT NULL,"password" VARCHAR NULL)
Migrating: CREATe TABLE "email"("id" SERIAL  PRIMARY KEY UNIQUE,"email" VARCHAR NOT NULL,"user" INT8 NULL,"verkey" VARCHAR NULL)
  • log: error
Migrating: ALTER TABLE "email" ADD CONSTRAINT "email_user_fkey" FOREIGN KEY("user") REFERENCES "user"("id")
devel.hs: SqlError {sqlState = "42804", sqlExecStatus = FatalError, sqlErrorMsg = "foreign key constraint \"email_user_fkey\" cannot be implemented", sqlErrorDetail = "Key columns \"user\" and \"id\" are of incompatible types: bigint and date.", sqlErrorHint = ""}
Exit code: ExitFailure 1

Is there any workaround?

Thank you.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions