Commit 6e568ac1 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Bookmark: Refactor schema member function

Sprinkling per-version modification isn't readable when there's more
than a couple changes
refs #429
parent 776d76c9
...@@ -157,25 +157,33 @@ std::string Bookmark::schema( const std::string& tableName, uint32_t dbModel ) ...@@ -157,25 +157,33 @@ std::string Bookmark::schema( const std::string& tableName, uint32_t dbModel )
assert( dbModel >= 17 ); assert( dbModel >= 17 );
assert( tableName == Table::Name ); assert( tableName == Table::Name );
std::string req = "CREATE TABLE " + Table::Name + if ( dbModel < 25 )
{
return "CREATE TABLE " + Table::Name +
"("
"id_bookmark INTEGER PRIMARY KEY AUTOINCREMENT,"
"time UNSIGNED INTEGER NOT NULL,"
"name TEXT,"
"description TEXT,"
"media_id UNSIGNED INTEGER NOT NULL,"
"FOREIGN KEY(media_id) REFERENCES " +
Media::Table::Name + "(id_media),"
"UNIQUE(time,media_id) ON CONFLICT FAIL"
")";
}
return "CREATE TABLE " + Table::Name +
"(" "("
"id_bookmark INTEGER PRIMARY KEY AUTOINCREMENT," "id_bookmark INTEGER PRIMARY KEY AUTOINCREMENT,"
"time UNSIGNED INTEGER NOT NULL," "time UNSIGNED INTEGER NOT NULL,"
"name TEXT," "name TEXT,"
"description TEXT," "description TEXT,"
"media_id UNSIGNED INTEGER NOT NULL,"; "media_id UNSIGNED INTEGER NOT NULL,"
"creation_date UNSIGNED INTEGER NOT NULL,"
if ( dbModel >= 25 ) "type UNSIGNED INTEGER NOT NULL,"
{ "FOREIGN KEY(media_id) REFERENCES " +
req += "creation_date UNSIGNED INTEGER NOT NULL," Media::Table::Name + "(id_media),"
"type UNSIGNED INTEGER NOT NULL,"; "UNIQUE(time,media_id) ON CONFLICT FAIL"
}
req += "FOREIGN KEY(media_id) REFERENCES " + Media::Table::Name +
"(id_media),"
"UNIQUE(time,media_id) ON CONFLICT FAIL"
")"; ")";
return req;
} }
std::string Bookmark::index( Indexes index, uint32_t dbModel ) std::string Bookmark::index( Indexes index, uint32_t dbModel )
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment