CREATE TABLE metadata(phash INTEGER(8),pathlen INTEGER,path VARCHAR(4096),inode INTEGER,uid INTEGER,gid INTEGER,mode INTEGER,modtime INTEGER(8),type INTEGER,md5 VARCHAR(32), fileid VARCHAR(128), remotePerm VARCHAR(128), filesize BIGINT, ignoredChildrenRemote INT, contentChecksum TEXT, contentChecksumTypeId INTEGER, e2eMangledName TEXT, isE2eEncrypted INTEGER, e2eCertificateFingerprint TEXT, isShared INTEGER, lastShareStateFetchedTimestmap INTEGER, sharedByMe INTEGER, lock INTEGER, lockType INTEGER, lockOwnerDisplayName TEXT, lockOwnerId TEXT, lockOwnerEditor TEXT, lockTime INTEGER, lockTimeout INTEGER, lockToken TEXT, isLivePhoto INTEGER, livePhotoFile TEXT, quotaBytesUsed BIGINT DEFAULT -1 NOT NULL, quotaBytesAvailable BIGINT DEFAULT -1 NOT NULL,PRIMARY KEY(phash));
CREATE TABLE key_value_store(key VARCHAR(4096), value VARCHAR(4096), PRIMARY KEY(key));
CREATE TABLE downloadinfo(path VARCHAR(4096),tmpfile VARCHAR(4096),etag VARCHAR(32),errorcount INTEGER,PRIMARY KEY(path));
CREATE TABLE uploadinfo(path VARCHAR(4096),chunk INTEGER,transferid INTEGER,errorcount INTEGER,size INTEGER(8),modtime INTEGER(8),contentChecksum TEXT,PRIMARY KEY(path));
CREATE TABLE blacklist (path VARCHAR(4096),lastTryEtag VARCHAR[32],lastTryModtime INTEGER[8],retrycount INTEGER,errorstring VARCHAR[4096], lastTryTime INTEGER(8), ignoreDuration INTEGER(8), renameTarget VARCHAR(4096), errorCategory INTEGER(8), requestId VARCHAR(36),PRIMARY KEY(path));
CREATE TABLE async_poll(path VARCHAR(4096),modtime INTEGER(8),filesize BIGINT,pollpath VARCHAR(4096));
CREATE TABLE selectivesync (path VARCHAR(4096),type INTEGER);
CREATE TABLE checksumtype(id INTEGER PRIMARY KEY,name TEXT UNIQUE);
CREATE TABLE datafingerprint(fingerprint TEXT UNIQUE);
CREATE TABLE flags (path TEXT PRIMARY KEY,pinState INTEGER);
CREATE TABLE conflicts(path TEXT PRIMARY KEY,baseFileId TEXT,baseEtag TEXT,baseModtime INTEGER, basePath TEXT);
CREATE TABLE caseconflicts(path TEXT PRIMARY KEY,baseFileId TEXT,baseEtag TEXT,baseModtime INTEGER,basePath TEXT UNIQUE);
CREATE TABLE version(major INTEGER(8),minor INTEGER(8),patch INTEGER(8),custom VARCHAR(256));
CREATE TABLE e2EeLockedFolders(folderId VARCHAR(128) PRIMARY KEY,token VARCHAR(4096));
CREATE INDEX metadata_fileid ON metadata(fileid);
CREATE INDEX metadata_inode ON metadata(inode);
CREATE INDEX metadata_path ON metadata(path);
CREATE INDEX metadata_parent ON metadata(parent_hash(path));
CREATE INDEX metadata_e2e_id ON metadata(e2eMangledName);
CREATE INDEX caseconflicts_basePath ON caseconflicts(basePath);
CREATE INDEX blacklist_index ON blacklist(path collate nocase);
CREATE INDEX metadata_e2e_status ON metadata (path, phash, type, isE2eEncrypted);
