The base schema for the Mixxx SQLITE database.
CREATE TABLE IF NOT EXISTS settings (
name TEXT UNIQUE NOT NULL,
value TEXT,
locked INTEGER DEFAULT 0,
hidden INTEGER DEFAULT 0);
CREATE TABLE IF NOT EXISTS track_locations (
id INTEGER PRIMARY KEY AUTOINCREMENT,
location varchar(512) UNIQUE,
filename varchar(512),
directory varchar(512),
filesize INTEGER,
fs_deleted INTEGER,
needs_verification INTEGER);
CREATE TABLE IF NOT EXISTS LibraryHashes (
directory_path VARCHAR(256) primary key,
hash INTEGER,
directory_deleted INTEGER);
CREATE TABLE IF NOT EXISTS library (
id INTEGER primary key AUTOINCREMENT,
artist varchar(48), title varchar(48),
album varchar(48), year varchar(16),
genre varchar(32), tracknumber varchar(3),
location varchar(512) REFERENCES track_locations(location),
comment varchar(20), url varchar(256),
duration float,
bitrate integer, samplerate integer,
cuepoint integer, bpm float,
wavesummaryhex blob,
channels integer,
datetime_added DEFAULT CURRENT_TIMESTAMP,
mixxx_deleted integer,
played integer);
CREATE TABLE Playlists (
id INTEGER primary key,
name varchar(48),
position INTEGER,
hidden INTEGER DEFAULT 0 NOT NULL,
date_created datetime,
date_modified datetime);
CREATE TABLE PlaylistTracks (
id INTEGER primary key,
playlist_id INTEGER REFERENCES Playlists(id),
track_id INTEGER REFERENCES library(id),
position INTEGER);
CREATE TABLE IF NOT EXISTS cues (
id integer PRIMARY KEY AUTOINCREMENT,
track_id integer NOT NULL REFERENCES library(id),
type integer DEFAULT 0 NOT NULL,
position integer DEFAULT -1 NOT NULL,
length integer DEFAULT 0 NOT NULL,
hotcue integer DEFAULT -1 NOT NULL,
label text DEFAULT '' NOT NULL);
CREATE TABLE IF NOT EXISTS crates (
id integer PRIMARY KEY AUTOINCREMENT,
name varchar(48) UNIQUE NOT NULL,
count integer DEFAULT 0,
show integer DEFAULT 1);
CREATE TABLE IF NOT EXISTS crate_tracks (
crate_id integer NOT NULL REFERENCES crates(id),
track_id integer NOT NULL REFERENCES library(id),
UNIQUE (crate_id, track_id));
Add a header_parsed integer column to the library to indicate when a
track's tags have been parsed.
ALTER TABLE library ADD COLUMN header_parsed integer DEFAULT 0;
Change the location column to be a an integer. Change comment to be
varchar(256) and album/artist/title to be varchar(64).
ALTER TABLE library RENAME TO library_old;
CREATE TABLE IF NOT EXISTS library (
id INTEGER primary key AUTOINCREMENT,
artist varchar(64),
title varchar(64),
album varchar(64),
year varchar(16),
genre varchar(64),
tracknumber varchar(3),
location integer REFERENCES track_locations(location),
comment varchar(256),
url varchar(256),
duration float,
bitrate integer,
samplerate integer,
cuepoint integer,
bpm float,
wavesummaryhex blob,
channels integer,
datetime_added DEFAULT CURRENT_TIMESTAMP,
mixxx_deleted integer,
played integer,
header_parsed integer DEFAULT 0);
INSERT INTO library (id, artist, title, album, year, genre, tracknumber, location, comment, url, duration, bitrate, samplerate, bpm, cuepoint, bpm, wavesummaryhex, channels, datetime_added, mixxx_deleted, played, header_parsed) SELECT id, artist, title, album, year, genre, tracknumber, location, comment, url, duration, bitrate, samplerate, bpm, cuepoint, bpm, wavesummaryhex, channels, datetime_added, mixxx_deleted, played, header_parsed from library_old;
DROP TABLE library_old;
Add file type column.
ALTER TABLE library ADD COLUMN filetype varchar(8) DEFAULT "?";
Add needs_verification column to library hashes table.
ALTER TABLE LibraryHashes ADD COLUMN needs_verification INTEGER DEFAULT 0;
Added a ReplayGain Column.
ALTER TABLE library ADD COLUMN replaygain float DEFAULT 0;
Add timesplayed and rating column. Reset header state.
ALTER TABLE library ADD COLUMN timesplayed integer DEFAULT 0;
ALTER TABLE library ADD COLUMN rating integer DEFAULT 0;
ALTER TABLE library ADD COLUMN key varchar(8) DEFAULT "";
UPDATE library SET timesplayed = played;
UPDATE library SET played = 0;
DELETE FROM settings WHERE name="mixxx.db.model.library.header_state";
DELETE FROM settings WHERE name="mixxx.db.model.playlist.header_state";
DELETE FROM settings WHERE name="mixxx.db.model.crate.header_state";
DELETE FROM settings WHERE name="mixxx.db.model.prepare.header_state";
DELETE FROM settings WHERE name="mixxx.db.model.missing.header_state";
Added iTunes tables
CREATE TABLE IF NOT EXISTS itunes_library (
id INTEGER primary key,
artist varchar(48), title varchar(48),
album varchar(48), year varchar(16),
genre varchar(32), tracknumber varchar(3),
location varchar(512),
comment varchar(60),
duration integer,
bitrate integer,
bpm integer,
rating integer);
CREATE TABLE IF NOT EXISTS itunes_playlists (
id INTEGER primary key,
name varchar(100) UNIQUE);
CREATE TABLE IF NOT EXISTS itunes_playlist_tracks (
id INTEGER primary key AUTOINCREMENT,
playlist_id INTEGER REFERENCES itunes_playlist(id),
track_id INTEGER REFERENCES itunes_library(id));
Tables for Traktor library feature
CREATE TABLE IF NOT EXISTS traktor_library (
id INTEGER primary key AUTOINCREMENT,
artist varchar(48), title varchar(48),
album varchar(48), year varchar(16),
genre varchar(32), tracknumber varchar(3),
location varchar(512) UNIQUE,
comment varchar(60),
duration integer,
bitrate integer,
bpm float,
key varchar(6),
rating integer
);
CREATE TABLE IF NOT EXISTS traktor_playlists (
id INTEGER primary key,
name varchar(100) UNIQUE
);
CREATE TABLE IF NOT EXISTS traktor_playlist_tracks (
id INTEGER primary key AUTOINCREMENT,
playlist_id INTEGER REFERENCES traktor_playlist(id),
track_id INTEGER REFERENCES traktor_library(id)
);
Playlist and crate locks
ALTER TABLE crates ADD COLUMN locked integer DEFAULT 0;
ALTER TABLE playlists ADD COLUMN locked integer DEFAULT 0;
Tables for Rhythmbox library feature
CREATE TABLE IF NOT EXISTS rhythmbox_library (
id INTEGER primary key AUTOINCREMENT,
artist varchar(48), title varchar(48),
album varchar(48), year varchar(16),
genre varchar(32), tracknumber varchar(3),
location varchar(512) UNIQUE,
comment varchar(60),
duration integer,
bitrate integer,
bpm float,
key varchar(6),
rating integer
);
CREATE TABLE IF NOT EXISTS rhythmbox_playlists (
id INTEGER primary key AUTOINCREMENT,
name varchar(100) UNIQUE
);
CREATE TABLE IF NOT EXISTS rhythmbox_playlist_tracks (
id INTEGER primary key AUTOINCREMENT,
playlist_id INTEGER REFERENCES rhythmbox_playlist(id),
track_id INTEGER REFERENCES rhythmbox_library(id)
);
Add beats column to library table.
ALTER TABLE Library ADD COLUMN beats BLOB;
ALTER TABLE Library ADD COLUMN beats_version TEXT;
Add position column to Rhythmbox, iTunes, and Traktor playlist tables.
ALTER TABLE itunes_playlist_tracks ADD COLUMN position INTEGER DEFAULT 0;
ALTER TABLE rhythmbox_playlist_tracks ADD COLUMN position INTEGER DEFAULT 0;
ALTER TABLE traktor_playlist_tracks ADD COLUMN position INTEGER DEFAULT 0;
Add composer column to library table.
ALTER TABLE library ADD COLUMN composer varchar(64) DEFAULT "";
Add datetime_added to playlists tracks.
ALTER TABLE PlaylistTracks ADD COLUMN pl_datetime_added;
Add track analysis table.
CREATE TABLE IF NOT EXISTS track_analysis (
id INTEGER primary key AUTOINCREMENT,
track_id INTEGER NOT NULL REFERENCES track_locations(id),
type varchar(512),
description varchar(1024),
version varchar(512),
created DEFAULT CURRENT_TIMESTAMP,
data_checksum varchar(512)
);
UPDATE library SET wavesummaryhex = '';
CREATE INDEX IF NOT EXISTS track_analysis_track_id_index ON track_analysis (track_id);
Add columns for BPM lock and a sub-version string for beats.
ALTER TABLE Library ADD COLUMN bpm_lock INTEGER DEFAULT 0;
ALTER TABLE Library ADD COLUMN beats_sub_version TEXT DEFAULT '';
Add keys column to library table.
ALTER TABLE Library ADD COLUMN keys BLOB;
ALTER TABLE Library ADD COLUMN keys_version TEXT;
ALTER TABLE Library ADD COLUMN keys_sub_version TEXT;
Add key_id column to library table for caching the global key. Default to
INVALID.
ALTER TABLE Library ADD COLUMN key_id INTEGER DEFAULT 0;
Crates in AutoDJ queue (for automated random-track selection).
ALTER TABLE crates ADD COLUMN autodj_source integer DEFAULT 0;
Add grouping and album_artist column to library table.
ALTER TABLE Library ADD COLUMN grouping TEXT DEFAULT "";
ALTER TABLE Library ADD COLUMN album_artist TEXT DEFAULT "";
Add grouping and album_artist column to itunes_library table.
ALTER TABLE itunes_library ADD COLUMN grouping TEXT DEFAULT "";
ALTER TABLE itunes_library ADD COLUMN album_artist TEXT DEFAULT "";
Add directories table
CREATE TABLE IF NOT EXISTS directories (
directory TEXT UNIQUE
);
Add cover art support. Default source is UNKNOWN and default type is NONE.
ALTER TABLE library ADD COLUMN coverart_source INTEGER DEFAULT 0;
ALTER TABLE library ADD COLUMN coverart_type INTEGER DEFAULT 0;
ALTER TABLE library ADD COLUMN coverart_location TEXT DEFAULT "";
ALTER TABLE library ADD COLUMN coverart_hash INTEGER DEFAULT 0;
Add full replay gain support including peak amplitude. The default
value for the peak amplitude is "undefined", represented by any
negative value. The internal constant for "undefined" is -1.0.
ALTER TABLE library ADD COLUMN replaygain_peak REAL DEFAULT -1.0;
Add new column "tracktotal" column that stores the total number of
tracks as a string. The total number of tracks will be reloaded
from the corresponding file upon first access when encountering
the default value.
ALTER TABLE library ADD COLUMN tracktotal TEXT DEFAULT '//';
Add cue color support. Default color is #FF0000.
ALTER TABLE cues ADD COLUMN color INTEGER DEFAULT 4294901760 NOT NULL;
Reset replay gain info for all FLAC files after fixing a decoding bug in version 2.1.0.
UPDATE library SET replaygain=0.0 WHERE filetype='flac' COLLATE NOCASE;
Add source to cue. Default is MANUAL.
ALTER TABLE cues ADD COLUMN source INTEGER DEFAULT 2 NOT NULL;