-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_function.sql
More file actions
106 lines (98 loc) · 3.39 KB
/
create_function.sql
File metadata and controls
106 lines (98 loc) · 3.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
-- Bu SQL kodunu Supabase SQL Editor'da çalıştırın
CREATE OR REPLACE FUNCTION create_table_if_not_exists(
table_name text,
columns text
)
RETURNS void AS $$
BEGIN
EXECUTE format('
CREATE TABLE IF NOT EXISTS %I (
%s
);
', table_name, columns);
END;
$$ LANGUAGE plpgsql SECURITY DEFINER;
-- Tabloları oluştur
DO $$
BEGIN
-- partner_system tablosu
IF NOT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = 'partner_system') THEN
CREATE TABLE public.partner_system (
id serial primary key,
key text unique not null,
value jsonb,
created_at timestamp with time zone default now(),
updated_at timestamp with time zone default now()
);
END IF;
-- partner_text tablosu
IF NOT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = 'partner_text') THEN
CREATE TABLE public.partner_text (
id serial primary key,
key text unique not null,
value jsonb,
created_at timestamp with time zone default now(),
updated_at timestamp with time zone default now()
);
END IF;
-- partner_count tablosu
IF NOT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = 'partner_count') THEN
CREATE TABLE public.partner_count (
id serial primary key,
key text unique not null,
value jsonb,
created_at timestamp with time zone default now(),
updated_at timestamp with time zone default now()
);
END IF;
-- partner_logs tablosu
IF NOT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = 'partner_logs') THEN
CREATE TABLE public.partner_logs (
id serial primary key,
key text unique not null,
value jsonb,
created_at timestamp with time zone default now(),
updated_at timestamp with time zone default now()
);
END IF;
-- partner_timestamps tablosu
IF NOT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = 'partner_timestamps') THEN
CREATE TABLE public.partner_timestamps (
id serial primary key,
key text unique not null,
value jsonb,
created_at timestamp with time zone default now(),
updated_at timestamp with time zone default now()
);
END IF;
-- banned_guilds tablosu
IF NOT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = 'banned_guilds') THEN
CREATE TABLE public.banned_guilds (
id serial primary key,
key text unique not null,
value jsonb,
created_at timestamp with time zone default now(),
updated_at timestamp with time zone default now()
);
END IF;
-- partner_toggle tablosu
IF NOT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = 'partner_toggle') THEN
CREATE TABLE public.partner_toggle (
id serial primary key,
key text unique not null,
value jsonb,
created_at timestamp with time zone default now(),
updated_at timestamp with time zone default now()
);
END IF;
-- guild_data tablosu
IF NOT EXISTS (SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = 'guild_data') THEN
CREATE TABLE public.guild_data (
id serial primary key,
key text unique not null,
value jsonb,
created_at timestamp with time zone default now(),
updated_at timestamp with time zone default now()
);
END IF;
END $$;