Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- drop table if exists users;
- create table users (
- id serial primary key,
- email varchar(255) not null check(strpos(email, '@') > 0),
- password varchar(255) not null check(password <> '')
- --, unique (lower(email)) не будет работать
- );
- create unique index email_unique_idx on users (lower(email));
- insert into users (email, password) values ('test@mail.com', 'test123'), ('TEST@mail.com', 'qweasd');
- -- ERROR: duplicate key value violates unique constraint "email_unique_idx"
- -- DETAIL: Key (lower(email::text))=(test@mail.com) already exists.
- -- SQL state: 23505
Add Comment
Please, Sign In to add comment