Some changes to DB schema.
This commit is contained in:
parent
fbfeb9f91b
commit
e4fe5a9f13
@ -74,10 +74,10 @@ CREATE TABLE IF NOT EXISTS Messages (
|
|||||||
is_read INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_read >= 0 AND is_read <= 1),
|
is_read INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_read >= 0 AND is_read <= 1),
|
||||||
is_deleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_deleted >= 0 AND is_deleted <= 1),
|
is_deleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_deleted >= 0 AND is_deleted <= 1),
|
||||||
is_important INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_important >= 0 AND is_important <= 1),
|
is_important INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_important >= 0 AND is_important <= 1),
|
||||||
feed TEXT,
|
feed TEXT NOT NULL,
|
||||||
title TEXT NOT NULL CHECK (title != ''),
|
title TEXT NOT NULL CHECK (title != ''),
|
||||||
url TEXT NOT NULL,
|
url TEXT NOT NULL,
|
||||||
author TEXT NOT NULL,
|
author TEXT,
|
||||||
date_created BIGINT NOT NULL CHECK (date_created != 0),
|
date_created BIGINT NOT NULL CHECK (date_created != 0),
|
||||||
contents TEXT,
|
contents TEXT,
|
||||||
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
|
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
|
||||||
|
@ -69,10 +69,10 @@ CREATE TABLE IF NOT EXISTS Messages (
|
|||||||
is_read INTEGER(1) NOT NULL CHECK (is_read >= 0 AND is_read <= 1) DEFAULT (0),
|
is_read INTEGER(1) NOT NULL CHECK (is_read >= 0 AND is_read <= 1) DEFAULT (0),
|
||||||
is_deleted INTEGER(1) NOT NULL CHECK (is_deleted >= 0 AND is_deleted <= 1) DEFAULT (0),
|
is_deleted INTEGER(1) NOT NULL CHECK (is_deleted >= 0 AND is_deleted <= 1) DEFAULT (0),
|
||||||
is_important INTEGER(1) NOT NULL CHECK (is_important >= 0 AND is_important <= 1) DEFAULT (0),
|
is_important INTEGER(1) NOT NULL CHECK (is_important >= 0 AND is_important <= 1) DEFAULT (0),
|
||||||
feed TEXT,
|
feed TEXT NOT NULL,
|
||||||
title TEXT NOT NULL CHECK (title != ''),
|
title TEXT NOT NULL CHECK (title != ''),
|
||||||
url TEXT NOT NULL,
|
url TEXT NOT NULL,
|
||||||
author TEXT NOT NULL,
|
author TEXT,
|
||||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||||
contents TEXT,
|
contents TEXT,
|
||||||
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
|
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
|
||||||
|
@ -38,7 +38,7 @@ ALTER TABLE Messages
|
|||||||
DROP FOREIGN KEY feed;
|
DROP FOREIGN KEY feed;
|
||||||
-- !
|
-- !
|
||||||
ALTER TABLE Messages
|
ALTER TABLE Messages
|
||||||
MODIFY Feeds TEXT;
|
MODIFY feed TEXT NOT NULL;
|
||||||
-- !
|
-- !
|
||||||
ALTER TABLE Feeds
|
ALTER TABLE Feeds
|
||||||
MODIFY date_created BIGINT;
|
MODIFY date_created BIGINT;
|
||||||
@ -55,4 +55,7 @@ MODIFY type INTEGER;
|
|||||||
ALTER TABLE Categories
|
ALTER TABLE Categories
|
||||||
MODIFY date_created BIGINT;
|
MODIFY date_created BIGINT;
|
||||||
-- !
|
-- !
|
||||||
|
ALTER TABLE Messages
|
||||||
|
MODIFY author TEXT;
|
||||||
|
-- !
|
||||||
UPDATE Information SET inf_value = '4' WHERE inf_key = 'schema_version';
|
UPDATE Information SET inf_value = '4' WHERE inf_key = 'schema_version';
|
@ -43,10 +43,10 @@ CREATE TABLE Messages (
|
|||||||
is_read INTEGER(1) NOT NULL CHECK (is_read >= 0 AND is_read <= 1) DEFAULT (0),
|
is_read INTEGER(1) NOT NULL CHECK (is_read >= 0 AND is_read <= 1) DEFAULT (0),
|
||||||
is_deleted INTEGER(1) NOT NULL CHECK (is_deleted >= 0 AND is_deleted <= 1) DEFAULT (0),
|
is_deleted INTEGER(1) NOT NULL CHECK (is_deleted >= 0 AND is_deleted <= 1) DEFAULT (0),
|
||||||
is_important INTEGER(1) NOT NULL CHECK (is_important >= 0 AND is_important <= 1) DEFAULT (0),
|
is_important INTEGER(1) NOT NULL CHECK (is_important >= 0 AND is_important <= 1) DEFAULT (0),
|
||||||
feed TEXT,
|
feed TEXT NOT NULL,
|
||||||
title TEXT NOT NULL CHECK (title != ''),
|
title TEXT NOT NULL CHECK (title != ''),
|
||||||
url TEXT NOT NULL,
|
url TEXT NOT NULL,
|
||||||
author TEXT NOT NULL,
|
author TEXT,
|
||||||
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
date_created INTEGER NOT NULL CHECK (date_created != 0),
|
||||||
contents TEXT,
|
contents TEXT,
|
||||||
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
|
is_pdeleted INTEGER(1) NOT NULL DEFAULT 0 CHECK (is_pdeleted >= 0 AND is_pdeleted <= 1),
|
||||||
|
@ -69,12 +69,12 @@ ServiceRoot *StandardServiceEntryPoint::createNewRoot() {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id_to_assing = query.value(0).toInt() + 1;
|
int id_to_assign = query.value(0).toInt() + 1;
|
||||||
|
|
||||||
if (query.exec(QString("INSERT INTO Accounts (id, type) VALUES (%1, '%2');").arg(QString::number(id_to_assing),
|
if (query.exec(QString("INSERT INTO Accounts (id, type) VALUES (%1, '%2');").arg(QString::number(id_to_assign),
|
||||||
SERVICE_CODE_STD_RSS))) {
|
SERVICE_CODE_STD_RSS))) {
|
||||||
StandardServiceRoot *root = new StandardServiceRoot();
|
StandardServiceRoot *root = new StandardServiceRoot();
|
||||||
root->setAccountId(id_to_assing);
|
root->setAccountId(id_to_assign);
|
||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include "services/tt-rss/network/ttrssnetworkfactory.h"
|
#include "services/tt-rss/network/ttrssnetworkfactory.h"
|
||||||
|
|
||||||
#include <QSqlQuery>
|
#include <QSqlQuery>
|
||||||
|
#include <QSqlError>
|
||||||
|
|
||||||
|
|
||||||
TtRssFeed::TtRssFeed(RootItem *parent)
|
TtRssFeed::TtRssFeed(RootItem *parent)
|
||||||
@ -251,6 +252,9 @@ int TtRssFeed::updateMessages(const QList<Message> &messages) {
|
|||||||
if (query_insert.exec() && query_insert.numRowsAffected() == 1) {
|
if (query_insert.exec() && query_insert.numRowsAffected() == 1) {
|
||||||
updated_messages++;
|
updated_messages++;
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
QString str = query_insert.lastError().text();
|
||||||
|
}
|
||||||
|
|
||||||
query_insert.finish();
|
query_insert.finish();
|
||||||
|
|
||||||
|
@ -82,6 +82,7 @@ QList<ServiceRoot*> TtRssServiceEntryPoint::initializeSubtree() {
|
|||||||
if (query.exec("SELECT id, username, password, url FROM TtRssAccounts;")) {
|
if (query.exec("SELECT id, username, password, url FROM TtRssAccounts;")) {
|
||||||
while (query.next()) {
|
while (query.next()) {
|
||||||
TtRssServiceRoot *root = new TtRssServiceRoot();
|
TtRssServiceRoot *root = new TtRssServiceRoot();
|
||||||
|
root->setId(query.value(0).toInt());
|
||||||
root->setAccountId(query.value(0).toInt());
|
root->setAccountId(query.value(0).toInt());
|
||||||
root->network()->setUsername(query.value(1).toString());
|
root->network()->setUsername(query.value(1).toString());
|
||||||
root->network()->setPassword(query.value(2).toString());
|
root->network()->setPassword(query.value(2).toString());
|
||||||
|
@ -251,17 +251,18 @@ void TtRssServiceRoot::saveAccountDataToDatabase() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id_to_assing = query.value(0).toInt() + 1;
|
int id_to_assign = query.value(0).toInt() + 1;
|
||||||
|
|
||||||
bool saved = query.exec(QString("INSERT INTO Accounts (id, type) VALUES (%1, '%2');").arg(QString::number(id_to_assing),
|
bool saved = query.exec(QString("INSERT INTO Accounts (id, type) VALUES (%1, '%2');").arg(QString::number(id_to_assign),
|
||||||
SERVICE_CODE_TT_RSS)) &&
|
SERVICE_CODE_TT_RSS)) &&
|
||||||
query.exec(QString("INSERT INTO TtRssAccounts (id, username, password, url) VALUES (%1, '%2', '%3', '%4');").arg(QString::number(id_to_assing),
|
query.exec(QString("INSERT INTO TtRssAccounts (id, username, password, url) VALUES (%1, '%2', '%3', '%4');").arg(QString::number(id_to_assign),
|
||||||
network()->username(),
|
network()->username(),
|
||||||
network()->password(),
|
network()->password(),
|
||||||
network()->url()));
|
network()->url()));
|
||||||
|
|
||||||
if (saved) {
|
if (saved) {
|
||||||
setAccountId(id_to_assing);
|
setId(id_to_assign);
|
||||||
|
setAccountId(id_to_assign);
|
||||||
updateTitle();
|
updateTitle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user