mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 03:19:46 +00:00
Trigger NOTIFY only on insert (not update)
This commit is contained in:
parent
053c362d44
commit
dd336232d5
1 changed files with 21 additions and 0 deletions
21
src/db/migrations/050_notify_only_insert.ts
Normal file
21
src/db/migrations/050_notify_only_insert.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { Kysely, sql } from 'kysely';
|
||||
|
||||
export async function up(db: Kysely<unknown>): Promise<void> {
|
||||
await sql`DROP TRIGGER IF EXISTS nostr_event_trigger ON nostr_events`.execute(db);
|
||||
|
||||
await sql`
|
||||
CREATE TRIGGER nostr_event_trigger
|
||||
AFTER INSERT ON nostr_events
|
||||
FOR EACH ROW EXECUTE FUNCTION notify_nostr_event()
|
||||
`.execute(db);
|
||||
}
|
||||
|
||||
export async function down(db: Kysely<unknown>): Promise<void> {
|
||||
await sql`DROP TRIGGER IF EXISTS nostr_event_trigger ON nostr_events`.execute(db);
|
||||
|
||||
await sql`
|
||||
CREATE TRIGGER nostr_event_trigger
|
||||
AFTER INSERT OR UPDATE ON nostr_events
|
||||
FOR EACH ROW EXECUTE FUNCTION notify_nostr_event()
|
||||
`.execute(db);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue