From: Andrew Dolgov Date: Wed, 17 Jun 2015 12:38:59 +0000 (+0300) Subject: bayes: add mysql script X-Git-Tag: 16.3~303 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=b02e8bc8f2f682077e41b0e4cc3c6a13a39d6fe3;hp=7c69068f82a12af4c98c6f4eb21b0b14b00fecad;p=tt-rss.git bayes: add mysql script --- diff --git a/plugins/af_sort_bayes/init.php b/plugins/af_sort_bayes/init.php index e7822c23..79d28715 100644 --- a/plugins/af_sort_bayes/init.php +++ b/plugins/af_sort_bayes/init.php @@ -96,25 +96,55 @@ class Af_Sort_Bayes extends Plugin { // PG only for the time being - $this->dbh->query("CREATE TABLE IF NOT EXISTS ${prefix}_categories ( - id SERIAL NOT NULL PRIMARY KEY, - category varchar(100) NOT NULL DEFAULT '', - probability DOUBLE PRECISION NOT NULL DEFAULT '0', - owner_uid INTEGER NOT NULL REFERENCES ttrss_users(id) ON DELETE CASCADE, - word_count BIGINT NOT NULL DEFAULT '0')"); - - $this->dbh->query("CREATE TABLE IF NOT EXISTS ${prefix}_references ( - id SERIAL NOT NULL PRIMARY KEY, - document_id VARCHAR(255) NOT NULL, - category_id INTEGER NOT NULL REFERENCES ${prefix}_categories(id) ON DELETE CASCADE, - owner_uid INTEGER NOT NULL REFERENCES ttrss_users(id) ON DELETE CASCADE, - content text NOT NULL)"); - - $this->dbh->query("CREATE TABLE IF NOT EXISTS ${prefix}_wordfreqs ( - word varchar(100) NOT NULL DEFAULT '', - category_id INTEGER NOT NULL REFERENCES ${prefix}_categories(id) ON DELETE CASCADE, - owner_uid INTEGER NOT NULL REFERENCES ttrss_users(id) ON DELETE CASCADE, - count BIGINT NOT NULL DEFAULT '0')"); + if (DB_TYPE == "mysql") { + + $this->dbh->query("CREATE TABLE IF NOT EXISTS ${prefix}_categories ( + id INTEGER NOT NULL PRIMARY KEY auto_increment, + category varchar(100) NOT NULL DEFAULT '', + probability DOUBLE NOT NULL DEFAULT '0', + owner_uid INTEGER NOT NULL, + FOREIGN KEY (owner_uid) REFERENCES ttrss_users(id) ON DELETE CASCADE, + word_count BIGINT NOT NULL DEFAULT '0') ENGINE=InnoDB"); + + $this->dbh->query("CREATE TABLE IF NOT EXISTS ${prefix}_references ( + id INTEGER NOT NULL PRIMARY KEY auto_increment, + document_id VARCHAR(255) NOT NULL, + category_id INTEGER NOT NULL, + FOREIGN KEY (category_id) REFERENCES ${prefix}_categories(id) ON DELETE CASCADE, + owner_uid INTEGER NOT NULL, + FOREIGN KEY (owner_uid) REFERENCES ttrss_users(id) ON DELETE CASCADE, + content text NOT NULL) ENGINE=InnoDB"); + + $this->dbh->query("CREATE TABLE IF NOT EXISTS ${prefix}_wordfreqs ( + word varchar(100) NOT NULL DEFAULT '', + category_id INTEGER NOT NULL, + FOREIGN KEY (category_id) REFERENCES ${prefix}_categories(id) ON DELETE CASCADE, + owner_uid INTEGER NOT NULL, + FOREIGN KEY (owner_uid) REFERENCES ttrss_users(id) ON DELETE CASCADE, + count BIGINT NOT NULL DEFAULT '0') ENGINE=InnoDB"); + + + } else { + $this->dbh->query("CREATE TABLE IF NOT EXISTS ${prefix}_categories ( + id SERIAL NOT NULL PRIMARY KEY, + category varchar(100) NOT NULL DEFAULT '', + probability DOUBLE NOT NULL DEFAULT '0', + owner_uid INTEGER NOT NULL REFERENCES ttrss_users(id) ON DELETE CASCADE, + word_count BIGINT NOT NULL DEFAULT '0')"); + + $this->dbh->query("CREATE TABLE IF NOT EXISTS ${prefix}_references ( + id SERIAL NOT NULL PRIMARY KEY, + document_id VARCHAR(255) NOT NULL, + category_id INTEGER NOT NULL REFERENCES ${prefix}_categories(id) ON DELETE CASCADE, + owner_uid INTEGER NOT NULL REFERENCES ttrss_users(id) ON DELETE CASCADE, + content text NOT NULL)"); + + $this->dbh->query("CREATE TABLE IF NOT EXISTS ${prefix}_wordfreqs ( + word varchar(100) NOT NULL DEFAULT '', + category_id INTEGER NOT NULL REFERENCES ${prefix}_categories(id) ON DELETE CASCADE, + owner_uid INTEGER NOT NULL REFERENCES ttrss_users(id) ON DELETE CASCADE, + count BIGINT NOT NULL DEFAULT '0')"); + } $owner_uid = @$_SESSION["uid"];