~aleteoryx/muditaos

92965078c19c64c489aef70f414d2d53f64137af — Tomek Sobkowiak 5 years ago 2aa015c
[EDG-4350] Load script to init notes database (#1023)

A image/user/db/notes_001.sql => image/user/db/notes_001.sql +6 -0
@@ 0,0 1,6 @@
CREATE TABLE IF NOT EXISTS notes(
    _id INTEGER PRIMARY KEY,
    date INTEGER,
    snippet TEXT DEFAULT '',
    path TEXT DEFAULT ''
);

A image/user/db/notes_002.sql => image/user/db/notes_002.sql +36 -0
@@ 0,0 1,36 @@
BEGIN;
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (1,1565586181,'snippet 1','/data/applications/notes/1565586181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (2,1565586381,'snippet 2
222
222
222','/data/applications/notes/1565586381.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (3,1565588181,'snippet 3
333333333333333333333333333333333333333333333333333','/data/applications/notes/1565588181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (4,1565596181,'snippet 4 4444444444444444444444444444444444444444444444444444444444444444444444444444','/data/applications/notes/1565596181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (5,1565606181,'snippet 5 555555
555555555
55555','/data/applications/notes/1565606181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (6,1565616181,'snippet 66666 66666 66666 66666 66666','/data/applications/notes/1565616181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (7,1565626181,'snippet 7
','/data/applications/notes/1565626181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (8,1565646181,'snippet 8

8','/data/applications/notes/1565646181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (9,1565666181,'snippet 9

9','/data/applications/notes/1565666181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (10,1565686181,'snippet 10
10

10','/data/applications/notes/1565686181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (11,1565706181,'snippet 11','/data/applications/notes/1565706181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (12,1565726181,'snippet 12','/data/applications/notes/1565726181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (13,1565746181,'snippet 13','/data/applications/notes/1565746181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (14,1565766181,'snippet 14','/data/applications/notes/1565766181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (15,1565786181,'snippet 15','/data/applications/notes/1565786181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (16,1565806181,'snippet 16
','/data/applications/notes/1565806181.txt');
INSERT OR IGNORE INTO notes ("_id","date","snippet","path") VALUES (17,1565826181,'snippet 17
17
17','/data/applications/notes/1565826181.txt');
COMMIT;

D image/user/notes.db => image/user/notes.db +0 -0
M module-db/Databases/NotesDB.cpp => module-db/Databases/NotesDB.cpp +0 -8
@@ 7,12 7,4 @@
const char *NotesDB::dbName = USER_PATH("notes.db");

NotesDB::NotesDB() : Database(dbName), notes(this)
{

    if (notes.create() == false)
        return;
    isInitialized_ = true;
}

NotesDB::~NotesDB()
{}

M module-db/Databases/NotesDB.hpp => module-db/Databases/NotesDB.hpp +1 -1
@@ 10,7 10,7 @@ class NotesDB : public Database
{
  public:
    NotesDB();
    virtual ~NotesDB();
    ~NotesDB() = default;

    NotesTable notes;


M module-db/Tables/NotesTable.cpp => module-db/Tables/NotesTable.cpp +1 -1
@@ 11,7 11,7 @@ NotesTable::~NotesTable()

bool NotesTable::create()
{
    return db->execute(createTableQuery);
    return true;
}

bool NotesTable::add(NotesTableRow entry)

M module-db/Tables/NotesTable.hpp => module-db/Tables/NotesTable.hpp +0 -7
@@ 47,11 47,4 @@ class NotesTable : public Table<NotesTableRow, NotesTableFields>

    uint32_t count() override final;
    uint32_t countByFieldId(const char *field, uint32_t id) override final;

  private:
    const char *createTableQuery = "CREATE TABLE IF NOT EXISTS notes("
                                   "_id INTEGER PRIMARY KEY,"
                                   "date INTEGER,"
                                   "snippet TEXT DEFAULT '',"
                                   "path TEXT DEFAULT '')";
};