-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathbtw.sql
More file actions
247 lines (211 loc) · 5.94 KB
/
btw.sql
File metadata and controls
247 lines (211 loc) · 5.94 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
-- -------------------------------------------------------------
-- Database: btw
-- Generation Time: 2023-06-04 14:36:11.7610
-- -------------------------------------------------------------
CREATE SCHEMA IF NOT EXISTS btw;
DROP TABLE IF EXISTS "btw"."custom_domains";
-- Sequence and defined type
CREATE SEQUENCE IF NOT EXISTS btw.custom_domains_id_seq;
-- Table Definition
CREATE TABLE "btw"."custom_domains" (
"id" int4 NOT NULL DEFAULT nextval('btw.custom_domains_id_seq'::regclass),
"domain" text NOT NULL,
"user_id" int4 NOT NULL,
"umami_site_id" uuid,
"share_id" text,
PRIMARY KEY ("domain","user_id")
);
DROP TABLE IF EXISTS "btw"."login_token";
-- Sequence and defined type
CREATE SEQUENCE IF NOT EXISTS btw.login_token_id_seq;
-- Table Definition
CREATE TABLE "btw"."login_token" (
"id" int4 NOT NULL DEFAULT nextval('btw.login_token_id_seq'::regclass),
"uuid" uuid NOT NULL,
"user_id" int4 NOT NULL,
"created_at" timestamptz NOT NULL,
"ip_address" text NOT NULL,
"fingerprint" text NOT NULL,
PRIMARY KEY ("uuid")
);
DROP TABLE IF EXISTS "btw"."notes";
-- Table Definition
CREATE TABLE "btw"."notes" (
"user_id" int4 NOT NULL,
"created_at" timestamptz NOT NULL,
"updated_at" timestamptz NOT NULL,
"json" json,
"html" text,
"title" text,
"id" uuid NOT NULL,
"ydoc" bytea,
"tags" text,
"published_at" timestamptz,
"slug" text,
"publish" bool,
"archive" bool,
"delete" bool,
"deleted_at" timestamptz,
"md" text,
"image" text,
"private" bool,
PRIMARY KEY ("id","user_id")
);
DROP TABLE IF EXISTS "btw"."otp";
-- Sequence and defined type
CREATE SEQUENCE IF NOT EXISTS btw.otp_id_seq;
-- Table Definition
CREATE TABLE "btw"."otp" (
"id" int4 NOT NULL DEFAULT nextval('btw.otp_id_seq'::regclass),
"created_at" timestamptz NOT NULL,
"email" text NOT NULL,
"processed_email" text NOT NULL,
"otp" text NOT NULL,
PRIMARY KEY ("id")
);
DROP TABLE IF EXISTS "btw"."users";
-- Sequence and defined type
CREATE SEQUENCE IF NOT EXISTS btw.user_id_seq;
-- Table Definition
CREATE TABLE "btw"."users" (
"id" int4 NOT NULL DEFAULT nextval('btw.user_id_seq'::regclass),
"email" text NOT NULL,
"processed_email" text NOT NULL,
"name" text,
"slug" text,
"created_at" timestamptz NOT NULL,
"bio" text,
"pic" varchar,
"twitter" varchar,
"instagram" varchar,
"linkedin" varchar,
"pro" bool,
"umami_site_id" uuid,
"share_id" text,
"settings" json,
PRIMARY KEY ("processed_email")
);
-- Table Definition
CREATE TABLE "btw"."nodes" (
"id" varchar NOT NULL,
"user_id" int4 NOT NULL,
"text" varchar,
"checked" bool,
"collapsed" bool,
"parent_id" varchar,
"pos" float4,
"updated_at" timestamptz,
"checked_date" timestamptz,
"pinned_pos" float4,
PRIMARY KEY ("id","user_id"),
"note_id" uuid,
"file_id" uuid
);
-- Table Definition
CREATE TABLE "btw"."files" (
"id" uuid NOT NULL,
"user_id" int4 NOT NULL,
"name" text,
"url" text,
"created_at" timestamptz,
"raw_text" text,
"structured_text" text,
"type" text,
"metadata" json,
PRIMARY KEY ("id","user_id")
);
-- Table Definition
CREATE TABLE "btw"."reminders" (
"user_id" int4 NOT NULL,
"duedate" timestamptz,
"created_at" timestamptz,
"updated_at" timestamptz,
"completed" bool,
"text" varchar,
"id" varchar,
"recurring" bool,
"crontab" text,
PRIMARY KEY ("user_id","id")
);
-- Sequence and defined type
CREATE SEQUENCE IF NOT EXISTS btw.alerts_id_seq;
-- Table Definition
CREATE TABLE "btw"."alerts" (
"id" int4 NOT NULL DEFAULT nextval('btw.alerts_id_seq'::regclass),
"reminder_id" varchar,
"user_id" int4,
"duedate" timestamptz,
PRIMARY KEY ("id")
);
CREATE TABLE "btw"."telegram_user_map" (
"telegram_id" numeric NOT NULL,
"user_id" int4 NOT NULL,
PRIMARY KEY ("telegram_id")
);
-- Sequence and defined type
CREATE SEQUENCE IF NOT EXISTS btw.telegram_chat_context_id_seq;
-- Table Definition
CREATE TABLE "btw"."telegram_chat_context" (
"id" int4 NOT NULL DEFAULT nextval('btw.telegram_chat_context_id_seq'::regclass),
"chat_id" numeric,
"added_at" timestamptz,
"message" jsonb,
"type" varchar,
"metadata" jsonb,
PRIMARY KEY ("id")
);
CREATE TABLE "btw"."whatsapp_user_map" (
"whatsapp_id" numeric NOT NULL,
"user_id" int4 NOT NULL,
PRIMARY KEY ("whatsapp_id")
);
-- Sequence and defined type
CREATE SEQUENCE IF NOT EXISTS btw.whatsapp_chat_context_id_seq;
-- Table Definition
CREATE TABLE "btw"."whatsapp_chat_context" (
"id" int4 NOT NULL DEFAULT nextval('btw.whatsapp_chat_context_id_seq'::regclass),
"chat_id" numeric,
"added_at" timestamptz,
"message" jsonb,
"type" varchar,
"metadata" jsonb,
PRIMARY KEY ("id")
);
-- Sequence and defined type
CREATE SEQUENCE IF NOT EXISTS btw.family_invites_id_seq;
-- Table Definition
CREATE TABLE "btw"."family_invites" (
"requester_user_id" int4,
"requested_family_number" varchar,
"notified" bool,
"requested_user_id" int4,
"created_on" timestamptz,
"id" int4 NOT NULL DEFAULT nextval('btw.family_invites_id_seq'::regclass),
PRIMARY KEY ("id")
);
-- Table Definition
CREATE TABLE "btw"."family_users" (
"id1" int4 NOT NULL,
"id2" int4 NOT NULL,
PRIMARY KEY ("id1","id2")
);
-- Table Definition
CREATE TABLE "btw"."memories" (
"id" uuid NOT NULL,
"user_id" int4 NOT NULL,
"name" text NOT NULL,
"place_name" text NOT NULL,
"place_address" text,
"latitude" float8 NOT NULL,
"longitude" float8 NOT NULL,
"place_type" text,
"city" text NOT NULL,
"country_code" text NOT NULL,
"description" text,
"photo_urls" jsonb,
"visited_date" timestamptz,
"private" boolean NOT NULL DEFAULT false,
"created_at" timestamptz NOT NULL DEFAULT NOW(),
"updated_at" timestamptz NOT NULL DEFAULT NOW(),
PRIMARY KEY ("id","user_id")
);