make quote nicks case insensitive

This commit is contained in:
2019-03-31 18:32:44 +00:00
parent 7255dd4735
commit 32c106fc90
2 changed files with 17 additions and 1 deletions

View File

@ -1,6 +1,6 @@
create table if not exists quotes (
id serial primary key,
nick varchar(30) not null,
nick citext not null,
item text not null,
channel varchar(32) not null,
created_by varchar(30) not null,
@ -72,3 +72,17 @@ create table if not exists last_messages (
item text not null,
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();