@vrplatform/kysely 1.3.45-4515 → 1.3.45-4535
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Kysely } from 'kysely';
|
|
2
|
+
import { sql } from 'kysely';
|
|
3
|
+
|
|
4
|
+
export async function up(db: Kysely<unknown>): Promise<void> {
|
|
5
|
+
await sql`
|
|
6
|
+
do $$
|
|
7
|
+
begin
|
|
8
|
+
if to_regprocedure('gen_random_bytes(integer)') is null
|
|
9
|
+
or to_regprocedure('digest(text,text)') is null
|
|
10
|
+
then
|
|
11
|
+
create extension if not exists pgcrypto;
|
|
12
|
+
end if;
|
|
13
|
+
|
|
14
|
+
if to_regprocedure('gen_random_bytes(integer)') is null
|
|
15
|
+
or to_regprocedure('digest(text,text)') is null
|
|
16
|
+
then
|
|
17
|
+
raise exception 'pgcrypto functions are unavailable';
|
|
18
|
+
end if;
|
|
19
|
+
end
|
|
20
|
+
$$
|
|
21
|
+
`.execute(db);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export async function down(): Promise<void> {
|
|
25
|
+
// Existing databases require pgcrypto for baseline functions, so rollback
|
|
26
|
+
// must not remove the extension.
|
|
27
|
+
}
|