aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/entry_limit_trigger.pgsql19
1 files changed, 19 insertions, 0 deletions
diff --git a/scripts/entry_limit_trigger.pgsql b/scripts/entry_limit_trigger.pgsql
new file mode 100644
index 0000000..d7d99c2
--- /dev/null
+++ b/scripts/entry_limit_trigger.pgsql
@@ -0,0 +1,19 @@
+CREATE OR REPLACE FUNCTION milla.janitor ()
+ RETURNS TRIGGER
+ AS $$
+BEGIN
+ UPDATE
+ posts
+ SET
+ updated_at = now()
+ WHERE
+ id = NEW.id;
+ RETURN new;
+END;
+$$
+LANGUAGE plpgsql;
+
+CREATE TRIGGER janitor_trigger
+ AFTER INSERT ON milla.tables
+ EXECUTE PROCEDURE milla.janitor ();
+