1CREATE TABLE "users" (
2 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
3 "github_login" VARCHAR,
4 "admin" BOOLEAN,
5 "email_address" VARCHAR(255) DEFAULT NULL,
6 "invite_code" VARCHAR(64),
7 "invite_count" INTEGER NOT NULL DEFAULT 0,
8 "inviter_id" INTEGER REFERENCES users (id),
9 "connected_once" BOOLEAN NOT NULL DEFAULT false,
10 "created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
11 "metrics_id" TEXT,
12 "github_user_id" INTEGER NOT NULL,
13 "accepted_tos_at" TIMESTAMP WITHOUT TIME ZONE,
14 "github_user_created_at" TIMESTAMP WITHOUT TIME ZONE,
15 "custom_llm_monthly_allowance_in_cents" INTEGER
16);
17CREATE UNIQUE INDEX "index_users_github_login" ON "users" ("github_login");
18CREATE UNIQUE INDEX "index_invite_code_users" ON "users" ("invite_code");
19CREATE INDEX "index_users_on_email_address" ON "users" ("email_address");
20CREATE UNIQUE INDEX "index_users_on_github_user_id" ON "users" ("github_user_id");
21
22CREATE TABLE "access_tokens" (
23 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
24 "user_id" INTEGER REFERENCES users (id),
25 "impersonated_user_id" INTEGER REFERENCES users (id),
26 "hash" VARCHAR(128)
27);
28CREATE INDEX "index_access_tokens_user_id" ON "access_tokens" ("user_id");
29
30CREATE TABLE "contacts" (
31 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
32 "user_id_a" INTEGER REFERENCES users (id) NOT NULL,
33 "user_id_b" INTEGER REFERENCES users (id) NOT NULL,
34 "a_to_b" BOOLEAN NOT NULL,
35 "should_notify" BOOLEAN NOT NULL,
36 "accepted" BOOLEAN NOT NULL
37);
38CREATE UNIQUE INDEX "index_contacts_user_ids" ON "contacts" ("user_id_a", "user_id_b");
39CREATE INDEX "index_contacts_user_id_b" ON "contacts" ("user_id_b");
40
41CREATE TABLE "rooms" (
42 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
43 "live_kit_room" VARCHAR NOT NULL,
44 "environment" VARCHAR,
45 "channel_id" INTEGER REFERENCES channels (id) ON DELETE CASCADE
46);
47CREATE UNIQUE INDEX "index_rooms_on_channel_id" ON "rooms" ("channel_id");
48
49CREATE TABLE "projects" (
50 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
51 "room_id" INTEGER REFERENCES rooms (id) ON DELETE CASCADE,
52 "host_user_id" INTEGER REFERENCES users (id),
53 "host_connection_id" INTEGER,
54 "host_connection_server_id" INTEGER REFERENCES servers (id) ON DELETE CASCADE,
55 "unregistered" BOOLEAN NOT NULL DEFAULT FALSE
56);
57CREATE INDEX "index_projects_on_host_connection_server_id" ON "projects" ("host_connection_server_id");
58CREATE INDEX "index_projects_on_host_connection_id_and_host_connection_server_id" ON "projects" ("host_connection_id", "host_connection_server_id");
59
60CREATE TABLE "worktrees" (
61 "project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
62 "id" INTEGER NOT NULL,
63 "root_name" VARCHAR NOT NULL,
64 "abs_path" VARCHAR NOT NULL,
65 "visible" BOOL NOT NULL,
66 "scan_id" INTEGER NOT NULL,
67 "is_complete" BOOL NOT NULL DEFAULT FALSE,
68 "completed_scan_id" INTEGER NOT NULL,
69 PRIMARY KEY(project_id, id)
70);
71CREATE INDEX "index_worktrees_on_project_id" ON "worktrees" ("project_id");
72
73CREATE TABLE "worktree_entries" (
74 "project_id" INTEGER NOT NULL,
75 "worktree_id" INTEGER NOT NULL,
76 "scan_id" INTEGER NOT NULL,
77 "id" INTEGER NOT NULL,
78 "is_dir" BOOL NOT NULL,
79 "path" VARCHAR NOT NULL,
80 "canonical_path" TEXT,
81 "inode" INTEGER NOT NULL,
82 "mtime_seconds" INTEGER NOT NULL,
83 "mtime_nanos" INTEGER NOT NULL,
84 "is_external" BOOL NOT NULL,
85 "is_ignored" BOOL NOT NULL,
86 "is_deleted" BOOL NOT NULL,
87 "git_status" INTEGER,
88 "is_fifo" BOOL NOT NULL,
89 PRIMARY KEY(project_id, worktree_id, id),
90 FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE
91);
92CREATE INDEX "index_worktree_entries_on_project_id" ON "worktree_entries" ("project_id");
93CREATE INDEX "index_worktree_entries_on_project_id_and_worktree_id" ON "worktree_entries" ("project_id", "worktree_id");
94
95CREATE TABLE "worktree_repositories" (
96 "project_id" INTEGER NOT NULL,
97 "worktree_id" INTEGER NOT NULL,
98 "work_directory_id" INTEGER NOT NULL,
99 "branch" VARCHAR,
100 "scan_id" INTEGER NOT NULL,
101 "is_deleted" BOOL NOT NULL,
102 PRIMARY KEY(project_id, worktree_id, work_directory_id),
103 FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE,
104 FOREIGN KEY(project_id, worktree_id, work_directory_id) REFERENCES worktree_entries (project_id, worktree_id, id) ON DELETE CASCADE
105);
106CREATE INDEX "index_worktree_repositories_on_project_id" ON "worktree_repositories" ("project_id");
107CREATE INDEX "index_worktree_repositories_on_project_id_and_worktree_id" ON "worktree_repositories" ("project_id", "worktree_id");
108
109CREATE TABLE "worktree_settings_files" (
110 "project_id" INTEGER NOT NULL,
111 "worktree_id" INTEGER NOT NULL,
112 "path" VARCHAR NOT NULL,
113 "content" TEXT,
114 "kind" VARCHAR,
115 PRIMARY KEY(project_id, worktree_id, path),
116 FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE
117);
118CREATE INDEX "index_worktree_settings_files_on_project_id" ON "worktree_settings_files" ("project_id");
119CREATE INDEX "index_worktree_settings_files_on_project_id_and_worktree_id" ON "worktree_settings_files" ("project_id", "worktree_id");
120
121CREATE TABLE "worktree_diagnostic_summaries" (
122 "project_id" INTEGER NOT NULL,
123 "worktree_id" INTEGER NOT NULL,
124 "path" VARCHAR NOT NULL,
125 "language_server_id" INTEGER NOT NULL,
126 "error_count" INTEGER NOT NULL,
127 "warning_count" INTEGER NOT NULL,
128 PRIMARY KEY(project_id, worktree_id, path),
129 FOREIGN KEY(project_id, worktree_id) REFERENCES worktrees (project_id, id) ON DELETE CASCADE
130);
131CREATE INDEX "index_worktree_diagnostic_summaries_on_project_id" ON "worktree_diagnostic_summaries" ("project_id");
132CREATE INDEX "index_worktree_diagnostic_summaries_on_project_id_and_worktree_id" ON "worktree_diagnostic_summaries" ("project_id", "worktree_id");
133
134CREATE TABLE "language_servers" (
135 "id" INTEGER NOT NULL,
136 "project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
137 "name" VARCHAR NOT NULL,
138 PRIMARY KEY(project_id, id)
139);
140CREATE INDEX "index_language_servers_on_project_id" ON "language_servers" ("project_id");
141
142CREATE TABLE "project_collaborators" (
143 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
144 "project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
145 "connection_id" INTEGER NOT NULL,
146 "connection_server_id" INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE,
147 "user_id" INTEGER NOT NULL,
148 "replica_id" INTEGER NOT NULL,
149 "is_host" BOOLEAN NOT NULL
150);
151CREATE INDEX "index_project_collaborators_on_project_id" ON "project_collaborators" ("project_id");
152CREATE UNIQUE INDEX "index_project_collaborators_on_project_id_and_replica_id" ON "project_collaborators" ("project_id", "replica_id");
153CREATE INDEX "index_project_collaborators_on_connection_server_id" ON "project_collaborators" ("connection_server_id");
154CREATE INDEX "index_project_collaborators_on_connection_id" ON "project_collaborators" ("connection_id");
155CREATE UNIQUE INDEX "index_project_collaborators_on_project_id_connection_id_and_server_id" ON "project_collaborators" ("project_id", "connection_id", "connection_server_id");
156
157CREATE TABLE "room_participants" (
158 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
159 "room_id" INTEGER NOT NULL REFERENCES rooms (id),
160 "user_id" INTEGER NOT NULL REFERENCES users (id),
161 "answering_connection_id" INTEGER,
162 "answering_connection_server_id" INTEGER REFERENCES servers (id) ON DELETE CASCADE,
163 "answering_connection_lost" BOOLEAN NOT NULL,
164 "location_kind" INTEGER,
165 "location_project_id" INTEGER,
166 "initial_project_id" INTEGER,
167 "calling_user_id" INTEGER NOT NULL REFERENCES users (id),
168 "calling_connection_id" INTEGER NOT NULL,
169 "calling_connection_server_id" INTEGER REFERENCES servers (id) ON DELETE SET NULL,
170 "participant_index" INTEGER,
171 "role" TEXT,
172 "in_call" BOOLEAN NOT NULL DEFAULT FALSE
173);
174CREATE UNIQUE INDEX "index_room_participants_on_user_id" ON "room_participants" ("user_id");
175CREATE INDEX "index_room_participants_on_room_id" ON "room_participants" ("room_id");
176CREATE INDEX "index_room_participants_on_answering_connection_server_id" ON "room_participants" ("answering_connection_server_id");
177CREATE INDEX "index_room_participants_on_calling_connection_server_id" ON "room_participants" ("calling_connection_server_id");
178CREATE INDEX "index_room_participants_on_answering_connection_id" ON "room_participants" ("answering_connection_id");
179CREATE UNIQUE INDEX "index_room_participants_on_answering_connection_id_and_answering_connection_server_id" ON "room_participants" ("answering_connection_id", "answering_connection_server_id");
180
181CREATE TABLE "servers" (
182 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
183 "environment" VARCHAR NOT NULL
184);
185
186CREATE TABLE "followers" (
187 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
188 "room_id" INTEGER NOT NULL REFERENCES rooms (id) ON DELETE CASCADE,
189 "project_id" INTEGER NOT NULL REFERENCES projects (id) ON DELETE CASCADE,
190 "leader_connection_server_id" INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE,
191 "leader_connection_id" INTEGER NOT NULL,
192 "follower_connection_server_id" INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE,
193 "follower_connection_id" INTEGER NOT NULL
194);
195CREATE UNIQUE INDEX
196 "index_followers_on_project_id_and_leader_connection_server_id_and_leader_connection_id_and_follower_connection_server_id_and_follower_connection_id"
197ON "followers" ("project_id", "leader_connection_server_id", "leader_connection_id", "follower_connection_server_id", "follower_connection_id");
198CREATE INDEX "index_followers_on_room_id" ON "followers" ("room_id");
199
200CREATE TABLE "channels" (
201 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
202 "name" VARCHAR NOT NULL,
203 "created_at" TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
204 "visibility" VARCHAR NOT NULL,
205 "parent_path" TEXT NOT NULL,
206 "requires_zed_cla" BOOLEAN NOT NULL DEFAULT FALSE
207);
208
209CREATE INDEX "index_channels_on_parent_path" ON "channels" ("parent_path");
210
211CREATE TABLE IF NOT EXISTS "channel_chat_participants" (
212 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
213 "user_id" INTEGER NOT NULL REFERENCES users (id),
214 "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
215 "connection_id" INTEGER NOT NULL,
216 "connection_server_id" INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE
217);
218CREATE INDEX "index_channel_chat_participants_on_channel_id" ON "channel_chat_participants" ("channel_id");
219
220CREATE TABLE IF NOT EXISTS "channel_messages" (
221 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
222 "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
223 "sender_id" INTEGER NOT NULL REFERENCES users (id),
224 "body" TEXT NOT NULL,
225 "sent_at" TIMESTAMP,
226 "edited_at" TIMESTAMP,
227 "nonce" BLOB NOT NULL,
228 "reply_to_message_id" INTEGER DEFAULT NULL
229);
230CREATE INDEX "index_channel_messages_on_channel_id" ON "channel_messages" ("channel_id");
231CREATE UNIQUE INDEX "index_channel_messages_on_sender_id_nonce" ON "channel_messages" ("sender_id", "nonce");
232
233CREATE TABLE "channel_message_mentions" (
234 "message_id" INTEGER NOT NULL REFERENCES channel_messages (id) ON DELETE CASCADE,
235 "start_offset" INTEGER NOT NULL,
236 "end_offset" INTEGER NOT NULL,
237 "user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
238 PRIMARY KEY(message_id, start_offset)
239);
240
241CREATE TABLE "channel_members" (
242 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
243 "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
244 "user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
245 "role" VARCHAR NOT NULL,
246 "accepted" BOOLEAN NOT NULL DEFAULT false,
247 "updated_at" TIMESTAMP NOT NULL DEFAULT now
248);
249
250CREATE UNIQUE INDEX "index_channel_members_on_channel_id_and_user_id" ON "channel_members" ("channel_id", "user_id");
251
252CREATE TABLE "buffers" (
253 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
254 "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
255 "epoch" INTEGER NOT NULL DEFAULT 0,
256 "latest_operation_epoch" INTEGER,
257 "latest_operation_replica_id" INTEGER,
258 "latest_operation_lamport_timestamp" INTEGER
259);
260
261CREATE INDEX "index_buffers_on_channel_id" ON "buffers" ("channel_id");
262
263CREATE TABLE "buffer_operations" (
264 "buffer_id" INTEGER NOT NULL REFERENCES buffers (id) ON DELETE CASCADE,
265 "epoch" INTEGER NOT NULL,
266 "replica_id" INTEGER NOT NULL,
267 "lamport_timestamp" INTEGER NOT NULL,
268 "value" BLOB NOT NULL,
269 PRIMARY KEY(buffer_id, epoch, lamport_timestamp, replica_id)
270);
271
272CREATE TABLE "buffer_snapshots" (
273 "buffer_id" INTEGER NOT NULL REFERENCES buffers (id) ON DELETE CASCADE,
274 "epoch" INTEGER NOT NULL,
275 "text" TEXT NOT NULL,
276 "operation_serialization_version" INTEGER NOT NULL,
277 PRIMARY KEY(buffer_id, epoch)
278);
279
280CREATE TABLE "channel_buffer_collaborators" (
281 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
282 "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
283 "connection_id" INTEGER NOT NULL,
284 "connection_server_id" INTEGER NOT NULL REFERENCES servers (id) ON DELETE CASCADE,
285 "connection_lost" BOOLEAN NOT NULL DEFAULT false,
286 "user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
287 "replica_id" INTEGER NOT NULL
288);
289
290CREATE INDEX "index_channel_buffer_collaborators_on_channel_id" ON "channel_buffer_collaborators" ("channel_id");
291CREATE UNIQUE INDEX "index_channel_buffer_collaborators_on_channel_id_and_replica_id" ON "channel_buffer_collaborators" ("channel_id", "replica_id");
292CREATE INDEX "index_channel_buffer_collaborators_on_connection_server_id" ON "channel_buffer_collaborators" ("connection_server_id");
293CREATE INDEX "index_channel_buffer_collaborators_on_connection_id" ON "channel_buffer_collaborators" ("connection_id");
294CREATE UNIQUE INDEX "index_channel_buffer_collaborators_on_channel_id_connection_id_and_server_id" ON "channel_buffer_collaborators" ("channel_id", "connection_id", "connection_server_id");
295
296
297CREATE TABLE "feature_flags" (
298 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
299 "flag" TEXT NOT NULL UNIQUE,
300 "enabled_for_all" BOOLEAN NOT NULL DEFAULT false
301);
302
303CREATE INDEX "index_feature_flags" ON "feature_flags" ("id");
304
305
306CREATE TABLE "user_features" (
307 "user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
308 "feature_id" INTEGER NOT NULL REFERENCES feature_flags (id) ON DELETE CASCADE,
309 PRIMARY KEY (user_id, feature_id)
310);
311
312CREATE UNIQUE INDEX "index_user_features_user_id_and_feature_id" ON "user_features" ("user_id", "feature_id");
313CREATE INDEX "index_user_features_on_user_id" ON "user_features" ("user_id");
314CREATE INDEX "index_user_features_on_feature_id" ON "user_features" ("feature_id");
315
316
317CREATE TABLE "observed_buffer_edits" (
318 "user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
319 "buffer_id" INTEGER NOT NULL REFERENCES buffers (id) ON DELETE CASCADE,
320 "epoch" INTEGER NOT NULL,
321 "lamport_timestamp" INTEGER NOT NULL,
322 "replica_id" INTEGER NOT NULL,
323 PRIMARY KEY (user_id, buffer_id)
324);
325
326CREATE UNIQUE INDEX "index_observed_buffers_user_and_buffer_id" ON "observed_buffer_edits" ("user_id", "buffer_id");
327
328CREATE TABLE IF NOT EXISTS "observed_channel_messages" (
329 "user_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
330 "channel_id" INTEGER NOT NULL REFERENCES channels (id) ON DELETE CASCADE,
331 "channel_message_id" INTEGER NOT NULL,
332 PRIMARY KEY (user_id, channel_id)
333);
334
335CREATE UNIQUE INDEX "index_observed_channel_messages_user_and_channel_id" ON "observed_channel_messages" ("user_id", "channel_id");
336
337CREATE TABLE "notification_kinds" (
338 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
339 "name" VARCHAR NOT NULL
340);
341
342CREATE UNIQUE INDEX "index_notification_kinds_on_name" ON "notification_kinds" ("name");
343
344CREATE TABLE "notifications" (
345 "id" INTEGER PRIMARY KEY AUTOINCREMENT,
346 "created_at" TIMESTAMP NOT NULL default CURRENT_TIMESTAMP,
347 "recipient_id" INTEGER NOT NULL REFERENCES users (id) ON DELETE CASCADE,
348 "kind" INTEGER NOT NULL REFERENCES notification_kinds (id),
349 "entity_id" INTEGER,
350 "content" TEXT,
351 "is_read" BOOLEAN NOT NULL DEFAULT FALSE,
352 "response" BOOLEAN
353);
354
355CREATE INDEX
356 "index_notifications_on_recipient_id_is_read_kind_entity_id"
357 ON "notifications"
358 ("recipient_id", "is_read", "kind", "entity_id");
359
360CREATE TABLE contributors (
361 user_id INTEGER REFERENCES users(id),
362 signed_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
363 PRIMARY KEY (user_id)
364);
365
366CREATE TABLE extensions (
367 id INTEGER PRIMARY KEY AUTOINCREMENT,
368 external_id TEXT NOT NULL,
369 name TEXT NOT NULL,
370 latest_version TEXT NOT NULL,
371 total_download_count INTEGER NOT NULL DEFAULT 0
372);
373
374CREATE TABLE extension_versions (
375 extension_id INTEGER REFERENCES extensions(id),
376 version TEXT NOT NULL,
377 published_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
378 authors TEXT NOT NULL,
379 repository TEXT NOT NULL,
380 description TEXT NOT NULL,
381 schema_version INTEGER NOT NULL DEFAULT 0,
382 wasm_api_version TEXT,
383 download_count INTEGER NOT NULL DEFAULT 0,
384 PRIMARY KEY (extension_id, version)
385);
386
387CREATE UNIQUE INDEX "index_extensions_external_id" ON "extensions" ("external_id");
388CREATE INDEX "index_extensions_total_download_count" ON "extensions" ("total_download_count");
389
390CREATE TABLE rate_buckets (
391 user_id INT NOT NULL,
392 rate_limit_name VARCHAR(255) NOT NULL,
393 token_count INT NOT NULL,
394 last_refill TIMESTAMP WITHOUT TIME ZONE NOT NULL,
395 PRIMARY KEY (user_id, rate_limit_name),
396 FOREIGN KEY (user_id) REFERENCES users(id)
397);
398CREATE INDEX idx_user_id_rate_limit ON rate_buckets (user_id, rate_limit_name);
399
400CREATE TABLE IF NOT EXISTS billing_preferences (
401 id INTEGER PRIMARY KEY AUTOINCREMENT,
402 created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
403 user_id INTEGER NOT NULL REFERENCES users(id),
404 max_monthly_llm_usage_spending_in_cents INTEGER NOT NULL
405);
406
407CREATE UNIQUE INDEX "uix_billing_preferences_on_user_id" ON billing_preferences (user_id);
408
409CREATE TABLE IF NOT EXISTS billing_customers (
410 id INTEGER PRIMARY KEY AUTOINCREMENT,
411 created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
412 user_id INTEGER NOT NULL REFERENCES users(id),
413 stripe_customer_id TEXT NOT NULL
414);
415
416CREATE UNIQUE INDEX "uix_billing_customers_on_user_id" ON billing_customers (user_id);
417CREATE UNIQUE INDEX "uix_billing_customers_on_stripe_customer_id" ON billing_customers (stripe_customer_id);
418
419CREATE TABLE IF NOT EXISTS billing_subscriptions (
420 id INTEGER PRIMARY KEY AUTOINCREMENT,
421 created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
422 billing_customer_id INTEGER NOT NULL REFERENCES billing_customers(id),
423 stripe_subscription_id TEXT NOT NULL,
424 stripe_subscription_status TEXT NOT NULL,
425 stripe_cancel_at TIMESTAMP
426);
427
428CREATE INDEX "ix_billing_subscriptions_on_billing_customer_id" ON billing_subscriptions (billing_customer_id);
429CREATE UNIQUE INDEX "uix_billing_subscriptions_on_stripe_subscription_id" ON billing_subscriptions (stripe_subscription_id);
430
431CREATE TABLE IF NOT EXISTS processed_stripe_events (
432 stripe_event_id TEXT PRIMARY KEY,
433 stripe_event_type TEXT NOT NULL,
434 stripe_event_created_timestamp INTEGER NOT NULL,
435 processed_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
436);
437
438CREATE INDEX "ix_processed_stripe_events_on_stripe_event_created_timestamp" ON processed_stripe_events (stripe_event_created_timestamp);