From 9991f02596903f15bea2161961a703e8538d87c6 Mon Sep 17 00:00:00 2001 From: Gao Sun Date: Fri, 11 Nov 2022 20:39:08 +0800 Subject: [PATCH] chore: add hooks alteration scripts --- .../alterations/next-1668170095-hooks.ts | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 packages/schemas/alterations/next-1668170095-hooks.ts diff --git a/packages/schemas/alterations/next-1668170095-hooks.ts b/packages/schemas/alterations/next-1668170095-hooks.ts new file mode 100644 index 000000000..1abd99523 --- /dev/null +++ b/packages/schemas/alterations/next-1668170095-hooks.ts @@ -0,0 +1,26 @@ +import { sql } from 'slonik'; + +import type { AlterationScript } from '../lib/types/alteration'; + +const alteration: AlterationScript = { + up: async (pool) => { + await pool.query(sql` + create table hooks ( + id varchar(128) not null, + event varchar(128) not null, + config jsonb /* @use HookConfig */ not null, + created_at timestamptz not null default(now()), + primary key (id) + ); + + create index hooks__event on hooks (event); + `); + }, + down: async (pool) => { + await pool.query(sql` + drop table hooks; + `); + }, +}; + +export default alteration;