Создать триггер для конкретного поля PostgreSQL

У меня есть две таблицы: издательства игр и сами игры.

create table "Companies" (
    name text not null primary key,
    email text not null,
    last_release timestamptz default current_timestamp not null
);

create table "Games" (
    id serial not null primary key,
    title text not null,
    version text not null,
    release date not null,
    genre text not null,
    author text not null references "Companies" (name)
);

Нужно создать триггер, чтобы last_release в "Companies" менялся на текущее время, когда поле version в "Games" изменялось или туда добавлялось новое значение. Возникли проблемы с написанием функции. Из того что есть:

create or replace function update_time()
            returns trigger as $u$
            begin 
                new.last_release = current_timestamp;
                return new;
            end;
        $u$ language plpgsql;

        drop trigger if exists trigger_update on "Games";

        create trigger trigger_update after insert or update on "Games".version
            for row execute procedure update_time();


Ответы (0 шт):