Skip to content

Instantly share code, notes, and snippets.

@dcposch
Created December 31, 2015 01:57
Show Gist options
  • Save dcposch/22919813c498850593ef to your computer and use it in GitHub Desktop.
Save dcposch/22919813c498850593ef to your computer and use it in GitHub Desktop.
--
-- Sqlite3 schema extracted from ~/.nylas/edgehill.db
--
CREATE TABLE `JSONObject` (key TEXT PRIMARY KEY, data BLOB);
CREATE UNIQUE INDEX `JSONObject_id` ON `JSONObject` (`key`);
CREATE TABLE `File` (id TEXT PRIMARY KEY,data BLOB,client_id TEXT,account_id TEXT,filename TEXT);
CREATE UNIQUE INDEX `File_id` ON `File` (`id`);
CREATE TABLE `Event` (id TEXT PRIMARY KEY,data BLOB,client_id TEXT,account_id TEXT,_start INTEGER,_end INTEGER);
CREATE UNIQUE INDEX `Event_id` ON `Event` (`id`);
CREATE TABLE `Label` (id TEXT PRIMARY KEY,data BLOB,client_id TEXT,account_id TEXT,name TEXT,display_name TEXT);
CREATE UNIQUE INDEX `Label_id` ON `Label` (`id`);
CREATE INDEX LabelNameIndex ON Label(account_id,name);
CREATE UNIQUE INDEX LabelClientIndex ON Label(client_id);
CREATE TABLE `Folder` (id TEXT PRIMARY KEY,data BLOB,client_id TEXT,account_id TEXT,name TEXT,display_name TEXT);
CREATE UNIQUE INDEX `Folder_id` ON `Folder` (`id`);
CREATE INDEX FolderNameIndex ON Folder(account_id,name);
CREATE UNIQUE INDEX FolderClientIndex ON Folder(client_id);
CREATE TABLE `Thread` (id TEXT PRIMARY KEY,data BLOB,client_id TEXT,account_id TEXT,subject TEXT,unread INTEGER,starred INTEGER,version INTEGER,last_message_received_timestamp INTEGER);
CREATE UNIQUE INDEX `Thread_id` ON `Thread` (`id`);
CREATE TABLE `Thread-Folder` (id TEXT KEY, `value` TEXT);
CREATE INDEX `Thread_Folder_id` ON `Thread-Folder` (`id` ASC);
CREATE UNIQUE INDEX `Thread_Folder_val_id` ON `Thread-Folder` (`value` ASC, `id` ASC);
CREATE TABLE `Thread-Label` (id TEXT KEY, `value` TEXT);
CREATE INDEX `Thread_Label_id` ON `Thread-Label` (`id` ASC);
CREATE UNIQUE INDEX `Thread_Label_val_id` ON `Thread-Label` (`value` ASC, `id` ASC);
CREATE INDEX ThreadListIndex ON Thread(account_id, last_message_received_timestamp DESC, id);
CREATE TABLE `Account` (id TEXT PRIMARY KEY,data BLOB,client_id TEXT,account_id TEXT,email_address TEXT);
CREATE UNIQUE INDEX `Account_id` ON `Account` (`id`);
CREATE TABLE `Message` (id TEXT PRIMARY KEY,data BLOB,client_id TEXT,account_id TEXT,date INTEGER,unread INTEGER,starred INTEGER,thread_id TEXT,draft INTEGER,version INTEGER);
CREATE UNIQUE INDEX `Message_id` ON `Message` (`id`);
CREATE TABLE `Message-Label` (id TEXT KEY, `value` TEXT);
CREATE INDEX `Message_Label_id` ON `Message-Label` (`id` ASC);
CREATE UNIQUE INDEX `Message_Label_val_id` ON `Message-Label` (`value` ASC, `id` ASC);
CREATE TABLE `MessageBody` (id TEXT PRIMARY KEY, `value` TEXT);
CREATE INDEX MessageListIndex ON Message(account_id, thread_id, date ASC);
CREATE INDEX MessageListThreadIndex ON Message(thread_id, date ASC);
CREATE INDEX MessageListDraftIndex ON Message(account_id, draft);
CREATE UNIQUE INDEX MessageDraftIndex ON Message(client_id);
CREATE UNIQUE INDEX MessageBodyIndex ON MessageBody(id);
CREATE TABLE `Contact` (id TEXT PRIMARY KEY,data BLOB,client_id TEXT,account_id TEXT,name TEXT,email TEXT);
CREATE UNIQUE INDEX `Contact_id` ON `Contact` (`id`);
CREATE INDEX ContactEmailIndex ON Contact(account_id,email);
CREATE TABLE `Category` (id TEXT PRIMARY KEY,data BLOB,client_id TEXT,account_id TEXT,name TEXT,display_name TEXT);
CREATE UNIQUE INDEX `Category_id` ON `Category` (`id`);
CREATE TABLE `Calendar` (id TEXT PRIMARY KEY,data BLOB,client_id TEXT,account_id TEXT);
CREATE UNIQUE INDEX `Calendar_id` ON `Calendar` (`id`);
CREATE TABLE `Metadata` (id TEXT PRIMARY KEY,data BLOB,client_id TEXT,account_id TEXT,type TEXT,publicId TEXT,key TEXT);
CREATE UNIQUE INDEX `Metadata_id` ON `Metadata` (`id`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment