Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introspection bug for @@unique name on MySQL #1774

Closed
Jolg42 opened this issue Mar 6, 2020 · 1 comment
Closed

Introspection bug for @@unique name on MySQL #1774

Jolg42 opened this issue Mar 6, 2020 · 1 comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug.

Comments

@Jolg42
Copy link
Member

Jolg42 commented Mar 6, 2020

In MySQL (8.0.19) the @@unique key is named email after introspection

create table users (
  id serial primary key not null,
  email varchar(50) not null,
  name varchar(50) not null,
  unique(email, name)
);
insert into users (email, name) values ('ada@prisma.io', 'Ada');

Introspection output

generator client {
  provider = "prisma-client-js"
  output   = "***"
}

datasource mysql {
  provider = "mysql"
  url      = "***"
}

model users {
  email String
  id    Int    @default(autoincrement()) @id
  name  String

  @@unique([email, name], name: "email")
}

This works in PostgreSQL, the @@unique key is named users_email_name_key after introspection

create table users (
  id serial primary key not null,
  email text not null,
  name text not null,
  unique(email, name)
);
insert into users ("email", "name") values ('ada@prisma.io', 'Ada');

Introspection output

generator client {
  provider = "prisma-client-js"
  output = "***"
}

datasource pg {
  provider = "postgresql"
  url = "***"
}

model users {
  email String
  id    Int    @default(autoincrement()) @id
  name  String

  @@unique([email, name], name: "users_email_name_key")
}
@Jolg42 Jolg42 added bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug. labels Mar 6, 2020
@Jolg42 Jolg42 added this to the Preview 24 New milestone Mar 6, 2020
@Jolg42
Copy link
Member Author

Jolg42 commented Mar 6, 2020

Looks like the default naming is different in MySQL and can be set like this

unique key users_email_name_key(email, name)

@Jolg42 Jolg42 closed this as completed Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/1-unconfirmed Bug should have enough information for reproduction, but confirmation has not happened yet. kind/bug A reported bug.
Projects
None yet
Development

No branches or pull requests

1 participant