· 8 years ago · Jan 23, 2018, 08:12 AM
1<?xml version="1.0" encoding="utf-8"?>
2<!--
3This is the Mixxx schema history file. It keeps track of internal changes to the
4Mixxx database schema and allows Mixxx to automatically upgrade itself to new
5revisions of the schema on a version upgrade.
6
7DO NOT EDIT THIS FILE OR YOU WILL BREAK YOUR MIXXX LIBRARY AND LOSE YOUR
8METADATA
9-->
10<schema>
11 <revision version="1">
12 <description>
13 The base schema for the Mixxx SQLITE database.
14 </description>
15 <sql>
16 CREATE TABLE IF NOT EXISTS settings (
17 name TEXT UNIQUE NOT NULL,
18 value TEXT,
19 locked INTEGER DEFAULT 0,
20 hidden INTEGER DEFAULT 0);
21
22 CREATE TABLE IF NOT EXISTS track_locations (
23 id INTEGER PRIMARY KEY AUTOINCREMENT,
24 location varchar(512) UNIQUE,
25 filename varchar(512),
26 directory varchar(512),
27 filesize INTEGER,
28 fs_deleted INTEGER,
29 needs_verification INTEGER);
30
31 CREATE TABLE IF NOT EXISTS LibraryHashes (
32 directory_path VARCHAR(256) primary key,
33 hash INTEGER,
34 directory_deleted INTEGER);
35
36 CREATE TABLE IF NOT EXISTS library (
37 id INTEGER primary key AUTOINCREMENT,
38 artist varchar(48), title varchar(48),
39 album varchar(48), year varchar(16),
40 genre varchar(32), tracknumber varchar(3),
41 location varchar(512) REFERENCES track_locations(location),
42 comment varchar(20), url varchar(256),
43 duration integer,
44 bitrate integer, samplerate integer,
45 cuepoint integer, bpm float,
46 wavesummaryhex blob,
47 channels integer,
48 datetime_added DEFAULT CURRENT_TIMESTAMP,
49 mixxx_deleted integer,
50 played integer);
51
52 CREATE TABLE Playlists (
53 id INTEGER primary key,
54 name varchar(48),
55 position INTEGER,
56 hidden INTEGER DEFAULT 0 NOT NULL,
57 date_created datetime,
58 date_modified datetime);
59
60 CREATE TABLE PlaylistTracks (
61 id INTEGER primary key,
62 playlist_id INTEGER REFERENCES Playlists(id),
63 track_id INTEGER REFERENCES library(id),
64 position INTEGER);
65
66 CREATE TABLE IF NOT EXISTS cues (
67 id integer PRIMARY KEY AUTOINCREMENT,
68 track_id integer NOT NULL REFERENCES library(id),
69 type integer DEFAULT 0 NOT NULL,
70 position integer DEFAULT -1 NOT NULL,
71 length integer DEFAULT 0 NOT NULL,
72 hotcue integer DEFAULT -1 NOT NULL,
73 label text DEFAULT '' NOT NULL);
74
75 CREATE TABLE IF NOT EXISTS crates (
76 id integer PRIMARY KEY AUTOINCREMENT,
77 name varchar(48) UNIQUE NOT NULL,
78 count integer DEFAULT 0,
79 show integer DEFAULT 1);
80
81 CREATE TABLE IF NOT EXISTS crate_tracks (
82 crate_id integer NOT NULL REFERENCES crates(id),
83 track_id integer NOT NULL REFERENCES library(id),
84 UNIQUE (crate_id, track_id));
85
86 </sql>
87 </revision>
88 <revision version="2">
89 <description>
90 Add a header_parsed integer column to the library to indicate when a
91 track's tags have been parsed.
92 </description>
93 <sql>
94 ALTER TABLE library ADD COLUMN header_parsed integer DEFAULT 0;
95 </sql>
96 </revision>
97 <revision version="3">
98 <description>
99 Change the location column to be a an integer. Change comment to be
100 varchar(256) and album/artist/title to be varchar(64).
101 </description>
102 <sql>
103 ALTER TABLE library RENAME TO library_old;
104
105 CREATE TABLE IF NOT EXISTS library (
106 id INTEGER primary key AUTOINCREMENT,
107 artist varchar(64),
108 title varchar(64),
109 album varchar(64),
110 year varchar(16),
111 genre varchar(64),
112 tracknumber varchar(3),
113 location integer REFERENCES track_locations(location),
114 comment varchar(256),
115 url varchar(256),
116 duration integer,
117 bitrate integer,
118 samplerate integer,
119 cuepoint integer,
120 bpm float,
121 wavesummaryhex blob,
122 channels integer,
123 datetime_added DEFAULT CURRENT_TIMESTAMP,
124 mixxx_deleted integer,
125 played integer,
126 header_parsed integer DEFAULT 0);
127
128 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;
129
130 DROP TABLE library_old;
131 </sql>
132 </revision>
133 <revision version="4">
134 <description>
135 Add file type column.
136 </description>
137 <sql>
138 ALTER TABLE library ADD COLUMN filetype varchar(8) DEFAULT "?";
139 </sql>
140 </revision>
141 <revision version="5">
142 <description>
143 Add needs_verification column to library hashes table.
144 </description>
145 <sql>
146 ALTER TABLE LibraryHashes ADD COLUMN needs_verification INTEGER DEFAULT 0;
147 </sql>
148 </revision>
149 <revision version="6">
150 <description>
151 Added a ReplayGain Column.
152 </description>
153 <sql>
154 ALTER TABLE library ADD COLUMN replaygain float DEFAULT 0;
155 </sql>
156 </revision>
157 <revision version="7" min_compatible="3">
158 <description>
159 Add timesplayed and rating column. Reset header state.
160 </description>
161 <sql>
162 ALTER TABLE library ADD COLUMN timesplayed integer DEFAULT 0;
163 ALTER TABLE library ADD COLUMN rating integer DEFAULT 0;
164 ALTER TABLE library ADD COLUMN key varchar(8) DEFAULT "";
165 UPDATE library SET timesplayed = played;
166 UPDATE library SET played = 0;
167
168 DELETE FROM settings WHERE name="mixxx.db.model.library.header_state";
169 DELETE FROM settings WHERE name="mixxx.db.model.playlist.header_state";
170 DELETE FROM settings WHERE name="mixxx.db.model.crate.header_state";
171 DELETE FROM settings WHERE name="mixxx.db.model.prepare.header_state";
172 DELETE FROM settings WHERE name="mixxx.db.model.missing.header_state";
173 </sql>
174 </revision>
175 <revision version="8" min_compatible="3">
176 <description>
177 Added iTunes tables
178 </description>
179 <sql>
180 CREATE TABLE IF NOT EXISTS itunes_library (
181 id INTEGER primary key,
182 artist varchar(48), title varchar(48),
183 album varchar(48), year varchar(16),
184 genre varchar(32), tracknumber varchar(3),
185 location varchar(512),
186 comment varchar(60),
187 duration integer,
188 bitrate integer,
189 bpm integer,
190 rating integer);
191
192 CREATE TABLE IF NOT EXISTS itunes_playlists (
193 id INTEGER primary key,
194 name varchar(100) UNIQUE);
195
196 CREATE TABLE IF NOT EXISTS itunes_playlist_tracks (
197 id INTEGER primary key AUTOINCREMENT,
198 playlist_id INTEGER REFERENCES itunes_playlist(id),
199 track_id INTEGER REFERENCES itunes_library(id));
200 </sql>
201 </revision>
202</schema>