You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.5 KiB
Python
61 lines
1.5 KiB
Python
TABLE_STATEMENT='''create table if not exists donor
|
|
(
|
|
user_id int not null,
|
|
name text null,
|
|
constraint donor_user_id_uindex
|
|
unique (user_id)
|
|
);
|
|
|
|
alter table donor
|
|
add primary key (user_id);
|
|
|
|
create table if not exists team
|
|
(
|
|
team_id int not null,
|
|
name text null,
|
|
constraint team_team_id_uindex
|
|
unique (team_id)
|
|
);
|
|
|
|
alter table team
|
|
add primary key (team_id);
|
|
|
|
create table if not exists donor_stats
|
|
(
|
|
id int auto_increment
|
|
primary key,
|
|
donor_id int null,
|
|
wus int null,
|
|
donor_rank int null,
|
|
credit int null,
|
|
team_id int null,
|
|
fetched_at datetime null,
|
|
constraint donor_stats_donor_user_id_fk
|
|
foreign key (donor_id) references donor (user_id),
|
|
constraint donor_stats_team_team_id_fk
|
|
foreign key (team_id) references team (team_id)
|
|
);
|
|
|
|
create index if not exists donor_stats_fetched_at_index
|
|
on donor_stats (fetched_at);
|
|
|
|
create table if not exists team_stats
|
|
(
|
|
id int not null
|
|
primary key,
|
|
wus int null,
|
|
team_rank int null,
|
|
total_teams int null,
|
|
active_50days int null,
|
|
last_update datetime null,
|
|
team_id int null,
|
|
credit int null,
|
|
fetched_at datetime null,
|
|
constraint team_stats_team_team_id_fk
|
|
foreign key (team_id) references team (team_id)
|
|
);
|
|
|
|
create index if not exists team_stats_fetched_at_index
|
|
on team_stats (fetched_at);
|
|
|
|
''' |