2021-06-27 13:31:30 -07:00
|
|
|
|
PRAGMA foreign_keys = on;
|
|
|
|
|
|
|
|
|
|
create table users (rowid integer primary key,
|
2021-07-24 21:52:39 -07:00
|
|
|
|
id integer unique not null check(typeof(id) = 'integer'),
|
2021-06-27 13:31:30 -07:00
|
|
|
|
display_name text not null,
|
|
|
|
|
handle text unique not null,
|
|
|
|
|
bio text,
|
2021-07-24 21:52:39 -07:00
|
|
|
|
following_count integer,
|
|
|
|
|
followers_count integer,
|
2021-06-27 13:31:30 -07:00
|
|
|
|
location text,
|
|
|
|
|
website text,
|
|
|
|
|
join_date integer,
|
|
|
|
|
is_private boolean default 0,
|
|
|
|
|
is_verified boolean default 0,
|
|
|
|
|
profile_image_url text,
|
2021-08-10 20:51:42 -07:00
|
|
|
|
profile_image_local_path text,
|
2021-06-27 13:31:30 -07:00
|
|
|
|
banner_image_url text,
|
2021-08-10 20:51:42 -07:00
|
|
|
|
banner_image_local_path text,
|
2021-07-25 15:42:43 -07:00
|
|
|
|
pinned_tweet_id integer check(typeof(pinned_tweet_id) = 'integer' or pinned_tweet_id = ''),
|
|
|
|
|
|
|
|
|
|
is_content_downloaded boolean default 0
|
2021-11-06 13:37:46 -07:00
|
|
|
|
);
|
2021-07-24 10:19:05 -07:00
|
|
|
|
|
2021-11-06 13:37:46 -07:00
|
|
|
|
create table tombstone_types (rowid integer primary key,
|
|
|
|
|
short_name text not null unique,
|
|
|
|
|
tombstone_text text not null unique
|
2021-06-27 13:31:30 -07:00
|
|
|
|
);
|
2021-11-06 13:37:46 -07:00
|
|
|
|
insert into tombstone_types(rowid, short_name, tombstone_text) values
|
|
|
|
|
(1, 'deleted', 'This Tweet was deleted by the Tweet author'),
|
|
|
|
|
(2, 'suspended', '???'),
|
|
|
|
|
(3, 'hidden', 'You’re unable to view this Tweet because this account owner limits who can view their Tweets'),
|
|
|
|
|
(4, 'unavailable', 'This Tweet is unavailable');
|
2021-06-27 13:31:30 -07:00
|
|
|
|
|
|
|
|
|
create table tweets (rowid integer primary key,
|
2021-07-24 21:52:39 -07:00
|
|
|
|
id integer unique not null check(typeof(id) = 'integer'),
|
2021-07-25 15:42:43 -07:00
|
|
|
|
user_id integer not null check(typeof(user_id) = 'integer'),
|
2021-06-27 13:31:30 -07:00
|
|
|
|
text text not null,
|
|
|
|
|
posted_at integer,
|
|
|
|
|
num_likes integer,
|
|
|
|
|
num_retweets integer,
|
|
|
|
|
num_replies integer,
|
|
|
|
|
num_quote_tweets integer,
|
2021-11-22 14:56:57 -08:00
|
|
|
|
in_reply_to_id integer,
|
|
|
|
|
quoted_tweet_id integer,
|
2021-09-27 18:29:55 -07:00
|
|
|
|
mentions text, -- comma-separated
|
|
|
|
|
reply_mentions text, -- comma-separated
|
|
|
|
|
hashtags text, -- comma-separated
|
2021-11-06 13:37:46 -07:00
|
|
|
|
tombstone_type integer default 0,
|
|
|
|
|
is_stub boolean default 0,
|
2021-06-27 13:31:30 -07:00
|
|
|
|
|
2021-07-25 15:42:43 -07:00
|
|
|
|
is_content_downloaded boolean default 0,
|
2021-12-20 14:07:20 -05:00
|
|
|
|
is_conversation_scraped boolean default 0,
|
|
|
|
|
last_scraped_at integer not null default 0,
|
2021-07-24 10:19:05 -07:00
|
|
|
|
foreign key(user_id) references users(id)
|
2021-06-27 13:31:30 -07:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
create table retweets(rowid integer primary key,
|
2021-08-16 20:37:35 -07:00
|
|
|
|
retweet_id integer not null unique,
|
2021-06-27 13:31:30 -07:00
|
|
|
|
tweet_id integer not null,
|
|
|
|
|
retweeted_by integer not null,
|
|
|
|
|
retweeted_at integer not null,
|
|
|
|
|
foreign key(tweet_id) references tweets(id)
|
|
|
|
|
foreign key(retweeted_by) references users(id)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
create table urls (rowid integer primary key,
|
|
|
|
|
tweet_id integer not null,
|
2021-09-17 18:04:12 -07:00
|
|
|
|
domain text,
|
2021-06-27 13:31:30 -07:00
|
|
|
|
text text not null,
|
2021-09-17 18:04:12 -07:00
|
|
|
|
title text,
|
|
|
|
|
description text,
|
|
|
|
|
creator_id integer,
|
|
|
|
|
site_id integer,
|
2021-10-10 16:06:47 -07:00
|
|
|
|
thumbnail_width integer not null,
|
|
|
|
|
thumbnail_height integer not null,
|
2021-09-17 18:04:12 -07:00
|
|
|
|
thumbnail_remote_url text,
|
|
|
|
|
thumbnail_local_path text,
|
|
|
|
|
has_card boolean,
|
2021-09-17 20:50:28 -07:00
|
|
|
|
has_thumbnail boolean,
|
2021-09-17 18:04:12 -07:00
|
|
|
|
is_content_downloaded boolean default 0,
|
2021-06-27 13:31:30 -07:00
|
|
|
|
|
|
|
|
|
unique (tweet_id, text)
|
|
|
|
|
foreign key(tweet_id) references tweets(id)
|
|
|
|
|
);
|
|
|
|
|
|
2021-12-12 16:42:32 -08:00
|
|
|
|
create table polls (rowid integer primary key,
|
2021-12-12 18:42:27 -08:00
|
|
|
|
id integer unique not null check(typeof(id) = 'integer'),
|
2021-12-12 16:42:32 -08:00
|
|
|
|
tweet_id integer not null,
|
|
|
|
|
num_choices integer not null,
|
|
|
|
|
|
|
|
|
|
choice1 text,
|
|
|
|
|
choice1_votes integer,
|
|
|
|
|
choice2 text,
|
|
|
|
|
choice2_votes integer,
|
|
|
|
|
choice3 text,
|
|
|
|
|
choice3_votes integer,
|
|
|
|
|
choice4 text,
|
|
|
|
|
choice4_votes integer,
|
|
|
|
|
|
|
|
|
|
voting_duration integer not null, -- in seconds
|
|
|
|
|
voting_ends_at integer not null,
|
|
|
|
|
|
|
|
|
|
last_scraped_at integer not null,
|
|
|
|
|
|
|
|
|
|
foreign key(tweet_id) references tweets(id)
|
|
|
|
|
);
|
|
|
|
|
|
2021-06-27 13:31:30 -07:00
|
|
|
|
create table images (rowid integer primary key,
|
2021-08-04 01:27:14 -07:00
|
|
|
|
id integer unique not null check(typeof(id) = 'integer'),
|
2021-06-27 13:31:30 -07:00
|
|
|
|
tweet_id integer not null,
|
2021-10-10 16:06:47 -07:00
|
|
|
|
width integer not null,
|
|
|
|
|
height integer not null,
|
2021-08-05 14:22:16 -07:00
|
|
|
|
remote_url text not null unique,
|
|
|
|
|
local_filename text not null unique,
|
2021-07-26 17:26:39 -07:00
|
|
|
|
is_downloaded boolean default 0,
|
2021-07-25 15:42:43 -07:00
|
|
|
|
|
|
|
|
|
foreign key(tweet_id) references tweets(id)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
create table videos (rowid integer primary key,
|
2021-08-04 23:41:58 -07:00
|
|
|
|
id integer unique not null check(typeof(id) = 'integer'),
|
2021-07-25 15:42:43 -07:00
|
|
|
|
tweet_id integer not null,
|
2021-10-10 16:06:47 -07:00
|
|
|
|
width integer not null,
|
|
|
|
|
height integer not null,
|
2021-08-05 14:10:46 -07:00
|
|
|
|
remote_url text not null unique,
|
|
|
|
|
local_filename text not null unique,
|
2021-10-04 21:06:53 -07:00
|
|
|
|
is_gif boolean default 0,
|
2021-07-26 17:26:39 -07:00
|
|
|
|
is_downloaded boolean default 0,
|
2021-06-27 13:31:30 -07:00
|
|
|
|
|
|
|
|
|
foreign key(tweet_id) references tweets(id)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
create table hashtags (rowid integer primary key,
|
|
|
|
|
tweet_id integer not null,
|
|
|
|
|
text text not null,
|
|
|
|
|
|
|
|
|
|
unique (tweet_id, text)
|
|
|
|
|
foreign key(tweet_id) references tweets(id)
|
|
|
|
|
);
|
2021-11-22 16:55:27 -08:00
|
|
|
|
|
|
|
|
|
create table database_version(rowid integer primary key,
|
|
|
|
|
version_number integer not null unique
|
|
|
|
|
);
|