1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-19 13:51:28 +00:00

bayes: add mysql script

This commit is contained in:
Andrew Dolgov
2015-06-17 15:38:59 +03:00
parent 7c69068f82
commit b02e8bc8f2

View File

@@ -96,10 +96,39 @@ class Af_Sort_Bayes extends Plugin {
// PG only for the time being // PG only for the time being
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 ( $this->dbh->query("CREATE TABLE IF NOT EXISTS ${prefix}_categories (
id SERIAL NOT NULL PRIMARY KEY, id SERIAL NOT NULL PRIMARY KEY,
category varchar(100) NOT NULL DEFAULT '', category varchar(100) NOT NULL DEFAULT '',
probability DOUBLE PRECISION NOT NULL DEFAULT '0', probability DOUBLE NOT NULL DEFAULT '0',
owner_uid INTEGER NOT NULL REFERENCES ttrss_users(id) ON DELETE CASCADE, owner_uid INTEGER NOT NULL REFERENCES ttrss_users(id) ON DELETE CASCADE,
word_count BIGINT NOT NULL DEFAULT '0')"); word_count BIGINT NOT NULL DEFAULT '0')");
@@ -115,6 +144,7 @@ class Af_Sort_Bayes extends Plugin {
category_id INTEGER NOT NULL REFERENCES ${prefix}_categories(id) ON DELETE CASCADE, category_id INTEGER NOT NULL REFERENCES ${prefix}_categories(id) ON DELETE CASCADE,
owner_uid INTEGER NOT NULL REFERENCES ttrss_users(id) ON DELETE CASCADE, owner_uid INTEGER NOT NULL REFERENCES ttrss_users(id) ON DELETE CASCADE,
count BIGINT NOT NULL DEFAULT '0')"); count BIGINT NOT NULL DEFAULT '0')");
}
$owner_uid = @$_SESSION["uid"]; $owner_uid = @$_SESSION["uid"];