aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-server-postgres/migrations/20230515221038_trigger-delete-only.sql
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-11 00:54:30 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2026-06-11 00:54:30 +0200
commit5c39e7cf284a1f6e9a1657f2deb44e359fc47eb8 (patch)
treec64baa8d5866c8e339eaf660dd3f94f30a3f7d8a /crates/atuin-server-postgres/migrations/20230515221038_trigger-delete-only.sql
parentchore: Somewhat simplify sync code (diff)
downloadatuin-5c39e7cf284a1f6e9a1657f2deb44e359fc47eb8.zip
chore: Move everything into one big crate
That helps remove duplicated code and rustc/cargo will now also show dead code correctly.
Diffstat (limited to 'crates/atuin-server-postgres/migrations/20230515221038_trigger-delete-only.sql')
-rw-r--r--crates/atuin-server-postgres/migrations/20230515221038_trigger-delete-only.sql30
1 files changed, 0 insertions, 30 deletions
diff --git a/crates/atuin-server-postgres/migrations/20230515221038_trigger-delete-only.sql b/crates/atuin-server-postgres/migrations/20230515221038_trigger-delete-only.sql
deleted file mode 100644
index 3d0bba52..00000000
--- a/crates/atuin-server-postgres/migrations/20230515221038_trigger-delete-only.sql
+++ /dev/null
@@ -1,30 +0,0 @@
--- We do not need to run the trigger on deletes, as the only time we are deleting history is when the user
--- has already been deleted
--- This actually slows down deleting all the history a good bit!
-
-create or replace function user_history_count()
-returns trigger as
-$func$
-begin
- if (TG_OP='INSERT') then
- update total_history_count_user set total = total + 1 where user_id = new.user_id;
-
- if not found then
- insert into total_history_count_user(user_id, total)
- values (
- new.user_id,
- (select count(1) from history where user_id = new.user_id)
- );
- end if;
- end if;
-
- return NEW; -- this is actually ignored for an after trigger, but oh well
-end;
-$func$
-language plpgsql volatile -- pldfplplpflh
-cost 100; -- default value
-
-create or replace trigger tg_user_history_count
- after insert on history
- for each row
- execute procedure user_history_count();