make quote nicks case insensitive
This commit is contained in:
parent
7255dd4735
commit
32c106fc90
|
@ -12,6 +12,8 @@ Create a user with password, allowed to login and a database:
|
||||||
CREATE ROLE nxy WITH ENCRYPTED PASSWORD 'your-password';
|
CREATE ROLE nxy WITH ENCRYPTED PASSWORD 'your-password';
|
||||||
ALTER ROLE nxy LOGIN;
|
ALTER ROLE nxy LOGIN;
|
||||||
CREATE DATABASE nxy_prod OWNER nxy;
|
CREATE DATABASE nxy_prod OWNER nxy;
|
||||||
|
\c nxy_prod
|
||||||
|
CREATE EXTENSION citext;
|
||||||
\q
|
\q
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
create table if not exists quotes (
|
create table if not exists quotes (
|
||||||
id serial primary key,
|
id serial primary key,
|
||||||
nick varchar(30) not null,
|
nick citext not null,
|
||||||
item text not null,
|
item text not null,
|
||||||
channel varchar(32) not null,
|
channel varchar(32) not null,
|
||||||
created_by varchar(30) not null,
|
created_by varchar(30) not null,
|
||||||
|
@ -72,3 +72,17 @@ create table if not exists last_messages (
|
||||||
item text not null,
|
item text not null,
|
||||||
unique (nick, channel)
|
unique (nick, channel)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
create or replace function quotes_ci_nick_insert_fnc()
|
||||||
|
returns trigger as $$
|
||||||
|
begin
|
||||||
|
NEW.nick = coalesce((select nick from quotes where nick = NEW.nick limit 1), NEW.nick);
|
||||||
|
return NEW;
|
||||||
|
end $$ language 'plpgsql';
|
||||||
|
|
||||||
|
drop trigger if exists quotes_ci_nick_trigger on quotes;
|
||||||
|
|
||||||
|
create trigger quotes_ci_nick_trigger
|
||||||
|
before insert on quotes
|
||||||
|
for each row
|
||||||
|
execute procedure quotes_ci_nick_insert_fnc();
|
||||||
|
|
Loading…
Reference in New Issue
Block a user