diff --git a/db/constraints.sql b/db/constraints.sql index bd27b52d1b..290435475a 100644 --- a/db/constraints.sql +++ b/db/constraints.sql @@ -180,7 +180,8 @@ alter table sent_email -- for delete account alter table consent - add index userid_cname(userid, consent_name); + add index userid_ctid(userid, consent_type_id); + add index consent_timestamp(consent_time); alter table consent_type add index consent_name(shortname); diff --git a/db/content.sql b/db/content.sql index 7512d4eb69..85de87f039 100644 --- a/db/content.sql +++ b/db/content.sql @@ -4,6 +4,6 @@ The table must be first defined in schema.sql before any content is added! */ -insert into consent_type (consent_id, shortname, description, enabled, protected, privacypref) +insert into consent_type (id, shortname, description, enabled, protected, privacypref) values (1, 'ENROLL', 'General terms-of-use for this BOINC project.', 0, 1, 0), (2, 'STATSEXPORT', 'Do you consent to exporting your data to BOINC statistics aggregation Web sites?', 0, 1, 1); diff --git a/db/schema.sql b/db/schema.sql index d383308cae..85ff5bc09d 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -809,7 +809,7 @@ create table host_deleted ( create table consent ( id integer not null auto_increment, userid integer not null, - consent_name varchar(255) not null, + consent_type_id integer not null, consent_time integer not null, consent_flag tinyint not null, consent_not_required tinyint not null, @@ -818,11 +818,11 @@ create table consent ( ) engine=InnoDB; create table consent_type ( - consent_id integer not null auto_increment, + id integer not null auto_increment, shortname varchar(255) not null, description varchar(255) not null, enabled integer not null, protected integer not null, privacypref integer not null, - primary key (consent_id) + primary key (id) ) engine=InnoDB; diff --git a/html/ops/db_update.php b/html/ops/db_update.php index f1574e7495..708584d792 100644 --- a/html/ops/db_update.php +++ b/html/ops/db_update.php @@ -1166,34 +1166,35 @@ function update_5_17_2018() { do_query("create table consent ( id integer not null auto_increment, userid integer not null, - consent_name varchar(255) not null, + consent_type_id integer not null, consent_time integer not null, consent_flag tinyint not null, consent_not_required tinyint not null, source varchar(255) not null, primary key (id), - index userid_cname (userid, consent_name) + index userid_ctid(userid, consent_type_id), + index consent_timestamp(consent_time) ) engine=InnoDB; "); do_query("create table consent_type ( - consent_id integer not null auto_increment, + id integer not null auto_increment, shortname varchar(255) not null, description varchar(255) not null, enabled integer not null, protected integer not null, privacypref integer not null, - primary key (consent_id), + primary key (id), index consent_name (shortname) ) engine=InnoDB; "); do_query("insert into consent_type - (consent_id, shortname, description, enabled, protected, privacypref) values + (id, shortname, description, enabled, protected, privacypref) values (1, 'ENROLL', 'General terms-of-use for this BOINC project.', 0, 1, 0); "); do_query("insert into consent_type - (consent_id, shortname, description, enabled, protected, privacypref) values + (id, shortname, description, enabled, protected, privacypref) values (2, 'STATSEXPORT', 'Do you consent to exporting your data to BOINC statistics aggregation Web sites?', 0, 1, 1); "); }