aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2024-06-11 14:13:13 +0000
committerterminaldweller <devi@terminaldweller.com>2024-06-11 14:13:13 +0000
commit556c839dc1b5881c1594dbdfede0bd610790967d (patch)
treef27987d2387fa86d3644df778c96491bd2bf7d1c /scripts
parentadded a new lua function, query_db (diff)
downloadmilla-556c839dc1b5881c1594dbdfede0bd610790967d.tar.gz
milla-556c839dc1b5881c1594dbdfede0bd610790967d.zip
added a shell.nix for pgformatter, and a wip trigger for db size maintenance
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 ();
+