From f9959a4fba4fc84b2abff6ee8a6d531263206a84 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Sun, 5 Dec 2010 10:55:21 +0000 Subject: [PATCH] Treat the Jamendo database schema the same as other databases. --- data/schema/schema-21.sql | 56 ++++++++++++++++++++++++++++++++++++--- src/core/database.cpp | 6 ----- 2 files changed, 53 insertions(+), 9 deletions(-) diff --git a/data/schema/schema-21.sql b/data/schema/schema-21.sql index c99efd7ed..af34e7537 100644 --- a/data/schema/schema-21.sql +++ b/data/schema/schema-21.sql @@ -1,4 +1,54 @@ -/* This file used to contain Jamendo schema, but it is now included in an - attached external database and created by jamendo.sql */ -SELECT 0; +/* Schema should be kept identical to the "songs" table, even though most of + it isn't used by jamendo */ +CREATE TABLE jamendo.songs ( + title TEXT, + album TEXT, + artist TEXT, + albumartist TEXT, + composer TEXT, + track INTEGER, + disc INTEGER, + bpm REAL, + year INTEGER, + genre TEXT, + comment TEXT, + compilation INTEGER, + + length INTEGER, + bitrate INTEGER, + samplerate INTEGER, + + directory INTEGER NOT NULL, + filename TEXT NOT NULL, + mtime INTEGER NOT NULL, + ctime INTEGER NOT NULL, + filesize INTEGER NOT NULL, + + sampler INTEGER NOT NULL DEFAULT 0, + art_automatic TEXT, + art_manual TEXT, + filetype INTEGER NOT NULL DEFAULT 0, + playcount INTEGER NOT NULL DEFAULT 0, + lastplayed INTEGER, + rating INTEGER, + forced_compilation_on INTEGER NOT NULL DEFAULT 0, + forced_compilation_off INTEGER NOT NULL DEFAULT 0, + effective_compilation NOT NULL DEFAULT 0, + skipcount NOT NULL DEFAULT 0, + score NOT NULL DEFAULT 0 +); + +CREATE VIRTUAL TABLE jamendo.songs_fts USING fts3( + ftstitle, ftsalbum, ftsartist, ftsalbumartist, ftscomposer, ftsgenre, ftscomment, + tokenize=unicode +); + +CREATE INDEX jamendo.idx_jamendo_comp_artist ON songs (effective_compilation, artist); + +CREATE TABLE jamendo.track_ids ( + songs_row_id INTEGER PRIMARY KEY, + track_id INTEGER +); + +CREATE INDEX jamendo.idx_jamendo_track_id ON track_ids(track_id); diff --git a/src/core/database.cpp b/src/core/database.cpp index 41ea41bfc..3992745f7 100644 --- a/src/core/database.cpp +++ b/src/core/database.cpp @@ -411,7 +411,6 @@ QSqlDatabase Database::Connect() { // Attach external databases foreach (const QString& key, attached_databases_.keys()) { const QString filename = attached_databases_[key].filename_; - const bool already_exists = QFile::exists(filename); // Attach the db QSqlQuery q("ATTACH DATABASE :filename AS :alias", db); @@ -420,11 +419,6 @@ QSqlDatabase Database::Connect() { if (!q.exec()) { qFatal("Couldn't attach external database '%s'", key.toAscii().constData()); } - - // Set up initial schema if it didn't exist already - if (!already_exists) { - ExecFromFile(attached_databases_[key].schema_, db); - } } // Get the database's schema version