CREATE TABLE IF NOT EXISTS actions(
	id serial PRIMARY KEY,
	description VARCHAR (500),
	created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
	updated_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);


CREATE OR REPLACE FUNCTION trigger_set_timestamp()
RETURNS TRIGGER AS $set_updated$
BEGIN
	NEW.updated_at = NOW();
	RETURN NEW;
END;
$set_updated$ LANGUAGE plpgsql;

CREATE TRIGGER set_updated
BEFORE UPDATE ON actions
FOR EACH ROW
EXECUTE PROCEDURE trigger_set_timestamp();
