Skip to content

Instantly share code, notes, and snippets.

@willscripted
Created June 18, 2015 22:21
Show Gist options
  • Save willscripted/465b913daf5dc186600b to your computer and use it in GitHub Desktop.
Save willscripted/465b913daf5dc186600b to your computer and use it in GitHub Desktop.
autoupdate
CREATE OR REPLACE FUNCTION update_modified_column()
RETURNS TRIGGER AS $$
BEGIN
NEW.updated_at = now();
RETURN NEW;
END;
$$ language 'plpgsql';
ALTER TABLE consumer_offsets ADD COLUMN updated_at timestamp default current_timestamp;
CREATE TRIGGER update_consumer_offsets_modtime BEFORE UPDATE ON consumer_offsets FOR EACH ROW EXECUTE PROCEDURE update_modified_column();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment