BEGIN;


CREATE TABLE product (
    id integer,
    name text
);

CREATE TABLE product_log (
    id integer,
    time timestamp
);

CREATE OR REPLACE FUNCTION insert_log() RETURNS trigger AS $$
BEGIN
    INSERT INTO product_log VALUES (new.id, current_timestamp);
    RETURN new;
END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER log_trigger AFTER INSERT ON product
    FOR EACH ROW EXECUTE PROCEDURE insert_log();

COMMIT;
