mirror of https://github.com/BOINC/boinc.git
db: Reorganize database changes, and add indices to new tables.
Added indices to consent and consent_type tables. Moved initial content of consent_type table to new SQL file: content.sql Modified database.py to insert new content.sql into database. In python autocommit is turned off by default, thus a manualy commit() was added. Updated db_update.php to match changes in db/.
This commit is contained in:
parent
8e023cc665
commit
cc6efacb8d
|
@ -178,3 +178,9 @@ alter table post_ratings
|
|||
alter table sent_email
|
||||
add index sent_email_userid(userid);
|
||||
-- for delete account
|
||||
|
||||
alter table consent
|
||||
add index userid_cname(userid, consent_name);
|
||||
|
||||
alter table consent_type
|
||||
add index consent_name(shortname);
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
/*
|
||||
This file contants inital content for any tables.
|
||||
|
||||
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)
|
||||
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);
|
|
@ -41,6 +41,8 @@
|
|||
-- fields ending with id (but not _id) are treated specially
|
||||
-- by the Python code (db_base.py)
|
||||
|
||||
-- Put initial content of any table in content.sql, and not in this file.
|
||||
|
||||
create table platform (
|
||||
id integer not null auto_increment,
|
||||
create_time integer not null,
|
||||
|
@ -824,7 +826,3 @@ create table consent_type (
|
|||
privacypref integer not null,
|
||||
primary key (consent_id)
|
||||
) engine=InnoDB;
|
||||
|
||||
insert into consent_type (consent_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);
|
||||
|
|
|
@ -1171,7 +1171,8 @@ function update_5_17_2018() {
|
|||
consent_flag tinyint not null,
|
||||
consent_not_required tinyint not null,
|
||||
source varchar(255) not null,
|
||||
primary key (id)
|
||||
primary key (id),
|
||||
index userid_cname (userid, consent_name)
|
||||
) engine=InnoDB;
|
||||
");
|
||||
|
||||
|
@ -1182,13 +1183,14 @@ function update_5_17_2018() {
|
|||
enabled integer not null,
|
||||
protected integer not null,
|
||||
privacypref integer not null,
|
||||
primary key (consent_id)
|
||||
primary key (consent_id),
|
||||
index consent_name (shortname)
|
||||
) engine=InnoDB;
|
||||
");
|
||||
|
||||
do_query("insert into consent_type
|
||||
(consent_id, shortname, description, enabled, protected, privacypref) values
|
||||
(1, 'ENROLL', 'General terms-of-use for this BOINC project.', 0, 1, 10);
|
||||
(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
|
||||
|
|
|
@ -281,13 +281,15 @@ def create_database(srcdir, config = None, drop_first = False):
|
|||
import boinc_path_config
|
||||
config = config or configxml.default_config().config
|
||||
connect(config, nodb=True)
|
||||
cursor = get_dbconnection().cursor()
|
||||
dbcon = get_dbconnection()
|
||||
cursor = dbcon.cursor()
|
||||
if drop_first:
|
||||
cursor.execute("drop database if exists %s"%config.db_name)
|
||||
cursor.execute("create database %s"%config.db_name)
|
||||
cursor.execute("use %s"%config.db_name)
|
||||
for file in ['schema.sql', 'constraints.sql']:
|
||||
for file in ['schema.sql', 'constraints.sql', 'content.sql']:
|
||||
_execute_sql_script(cursor, os.path.join(srcdir, 'db', file))
|
||||
dbcon.commit()
|
||||
cursor.close()
|
||||
|
||||
# alias
|
||||
|
|
Loading…
Reference in New Issue