Fix MC bug reported by felix
[dbsrgits/DBIx-Class.git] / t / lib / sqlite.sql
CommitLineData
243e940e 1--
2-- Created by SQL::Translator::Producer::SQLite
68888c09 3-- Created on Sun Mar 7 11:14:14 2010
0009fa49 4--
181b2261 5;
084a2c0a 6
0009fa49 7--
8-- Table: artist
9--
10CREATE TABLE artist (
11 artistid INTEGER PRIMARY KEY NOT NULL,
39da2a2b 12 name varchar(100),
a0dd8679 13 rank integer NOT NULL DEFAULT '13',
14 charfield char(10)
0009fa49 15);
16
0fd7e9a3 17CREATE INDEX artist_name_hookidx ON artist (name);
18
0009fa49 19--
6ec7d1bb 20-- Table: bindtype_test
21--
22CREATE TABLE bindtype_test (
23 id INTEGER PRIMARY KEY NOT NULL,
24 bytea blob,
25 blob blob,
26 clob clob
27);
28
6ec7d1bb 29--
ebf846e8 30-- Table: collection
0009fa49 31--
ebf846e8 32CREATE TABLE collection (
33 collectionid INTEGER PRIMARY KEY NOT NULL,
34 name varchar(100) NOT NULL
0009fa49 35);
36
37--
084a2c0a 38-- Table: encoded
39--
40CREATE TABLE encoded (
41 id INTEGER PRIMARY KEY NOT NULL,
42 encoded varchar(100)
43);
ebf846e8 44
9fcda149 45--
ebf846e8 46-- Table: event
ab8481f5 47--
ebf846e8 48CREATE TABLE event (
ab8481f5 49 id INTEGER PRIMARY KEY NOT NULL,
ebf846e8 50 starts_at datetime NOT NULL,
a97fe7e0 51 created_on timestamp NOT NULL,
52 varchar_date varchar(20),
ff8a6e3b 53 varchar_datetime varchar(20),
41308e82 54 skip_inflation datetime,
55 ts_without_tz datetime
ab8481f5 56);
57
58--
823c91a1 59-- Table: file_columns
60--
61CREATE TABLE file_columns (
62 id INTEGER PRIMARY KEY NOT NULL,
63 file varchar(255) NOT NULL
64);
65
66--
ebf846e8 67-- Table: fourkeys
9c2c91ea 68--
ebf846e8 69CREATE TABLE fourkeys (
70 foo integer NOT NULL,
71 bar integer NOT NULL,
72 hello integer NOT NULL,
73 goodbye integer NOT NULL,
ff1234ad 74 sensors character(10) NOT NULL,
75 read_count integer,
ebf846e8 76 PRIMARY KEY (foo, bar, hello, goodbye)
0009fa49 77);
78
79--
ebf846e8 80-- Table: genre
887ce227 81--
ebf846e8 82CREATE TABLE genre (
87310237 83 genreid INTEGER PRIMARY KEY NOT NULL,
56b73f83 84 name varchar(100) NOT NULL
9c2c91ea 85);
86
eb0bc670 87CREATE UNIQUE INDEX genre_name ON genre (name);
ebf846e8 88
89--
90-- Table: link
91--
92CREATE TABLE link (
93 id INTEGER PRIMARY KEY NOT NULL,
94 url varchar(100),
95 title varchar(100)
96);
97
9c2c91ea 98--
41308e82 99-- Table: money_test
100--
101CREATE TABLE money_test (
102 id INTEGER PRIMARY KEY NOT NULL,
103 amount money
104);
105
106--
89034887 107-- Table: noprimarykey
108--
109CREATE TABLE noprimarykey (
110 foo integer NOT NULL,
111 bar integer NOT NULL,
112 baz integer NOT NULL
113);
114
eb0bc670 115CREATE UNIQUE INDEX foo_bar ON noprimarykey (foo, bar);
ebf846e8 116
89034887 117--
ebf846e8 118-- Table: onekey
9c2c91ea 119--
ebf846e8 120CREATE TABLE onekey (
121 id INTEGER PRIMARY KEY NOT NULL,
122 artist integer NOT NULL,
123 cd integer NOT NULL
9c2c91ea 124);
125
126--
ebf846e8 127-- Table: owners
9c2c91ea 128--
ebf846e8 129CREATE TABLE owners (
bed3a173 130 id INTEGER PRIMARY KEY NOT NULL,
ebf846e8 131 name varchar(100) NOT NULL
9c2c91ea 132);
133
134--
135-- Table: producer
136--
137CREATE TABLE producer (
138 producerid INTEGER PRIMARY KEY NOT NULL,
8fcf21b3 139 name varchar(100) NOT NULL
887ce227 140);
141
eb0bc670 142CREATE UNIQUE INDEX prod_name ON producer (name);
ebf846e8 143
9fcda149 144--
ebf846e8 145-- Table: self_ref
9fcda149 146--
ebf846e8 147CREATE TABLE self_ref (
8fcf21b3 148 id INTEGER PRIMARY KEY NOT NULL,
ebf846e8 149 name varchar(100) NOT NULL
9fcda149 150);
151
78060df8 152--
ebf846e8 153-- Table: sequence_test
78060df8 154--
ebf846e8 155CREATE TABLE sequence_test (
156 pkid1 integer NOT NULL,
157 pkid2 integer NOT NULL,
158 nonpkid integer NOT NULL,
159 name varchar(100),
160 PRIMARY KEY (pkid1, pkid2)
78060df8 161);
162
163--
ebf846e8 164-- Table: serialized
78060df8 165--
ebf846e8 166CREATE TABLE serialized (
167 id INTEGER PRIMARY KEY NOT NULL,
168 serialized text NOT NULL
78060df8 169);
170
171--
eb0bc670 172-- Table: treelike
78060df8 173--
eb0bc670 174CREATE TABLE treelike (
175 id INTEGER PRIMARY KEY NOT NULL,
176 parent integer,
177 name varchar(100) NOT NULL
178);
179
180CREATE INDEX treelike_idx_parent ON treelike (parent);
181
182--
183-- Table: twokeytreelike
184--
185CREATE TABLE twokeytreelike (
186 id1 integer NOT NULL,
187 id2 integer NOT NULL,
188 parent1 integer NOT NULL,
189 parent2 integer NOT NULL,
190 name varchar(100) NOT NULL,
191 PRIMARY KEY (id1, id2)
192);
193
194CREATE INDEX twokeytreelike_idx_parent1_parent2 ON twokeytreelike (parent1, parent2);
195
196CREATE UNIQUE INDEX tktlnameunique ON twokeytreelike (name);
197
198--
199-- Table: typed_object
200--
201CREATE TABLE typed_object (
202 objectid INTEGER PRIMARY KEY NOT NULL,
203 type varchar(100) NOT NULL,
204 value varchar(100) NOT NULL
205);
206
207--
208-- Table: artist_undirected_map
209--
210CREATE TABLE artist_undirected_map (
211 id1 integer NOT NULL,
212 id2 integer NOT NULL,
213 PRIMARY KEY (id1, id2)
214);
215
216CREATE INDEX artist_undirected_map_idx_id1 ON artist_undirected_map (id1);
217
218CREATE INDEX artist_undirected_map_idx_id2 ON artist_undirected_map (id2);
219
220--
221-- Table: bookmark
222--
223CREATE TABLE bookmark (
224 id INTEGER PRIMARY KEY NOT NULL,
41308e82 225 link integer
eb0bc670 226);
227
228CREATE INDEX bookmark_idx_link ON bookmark (link);
229
230--
231-- Table: books
232--
233CREATE TABLE books (
234 id INTEGER PRIMARY KEY NOT NULL,
235 source varchar(100) NOT NULL,
236 owner integer NOT NULL,
237 title varchar(100) NOT NULL,
238 price integer
239);
240
241CREATE INDEX books_idx_owner ON books (owner);
242
243--
68888c09 244-- Table: employee
245--
246CREATE TABLE employee (
247 employee_id INTEGER PRIMARY KEY NOT NULL,
248 position integer NOT NULL,
249 group_id integer,
250 group_id_2 integer,
251 group_id_3 integer,
252 name varchar(100),
253 encoded integer
254);
255
256CREATE INDEX employee_idx_encoded ON employee (encoded);
257
258--
eb0bc670 259-- Table: forceforeign
260--
261CREATE TABLE forceforeign (
262 artist INTEGER PRIMARY KEY NOT NULL,
263 cd integer NOT NULL
264);
265
eb0bc670 266--
267-- Table: self_ref_alias
268--
269CREATE TABLE self_ref_alias (
270 self_ref integer NOT NULL,
271 alias integer NOT NULL,
272 PRIMARY KEY (self_ref, alias)
78060df8 273);
274
eb0bc670 275CREATE INDEX self_ref_alias_idx_alias ON self_ref_alias (alias);
276
277CREATE INDEX self_ref_alias_idx_self_ref ON self_ref_alias (self_ref);
ebf846e8 278
78060df8 279--
ebf846e8 280-- Table: track
78060df8 281--
ebf846e8 282CREATE TABLE track (
283 trackid INTEGER PRIMARY KEY NOT NULL,
284 cd integer NOT NULL,
c1d7087d 285 position int NOT NULL,
ebf846e8 286 title varchar(100) NOT NULL,
abc914bd 287 last_updated_on datetime,
09451687 288 last_updated_at datetime,
c0678cfc 289 small_dt smalldatetime
ebf846e8 290);
291
eb0bc670 292CREATE INDEX track_idx_cd ON track (cd);
084a2c0a 293
eb0bc670 294CREATE UNIQUE INDEX track_cd_position ON track (cd, position);
084a2c0a 295
eb0bc670 296CREATE UNIQUE INDEX track_cd_title ON track (cd, title);
ebf846e8 297
298--
eb0bc670 299-- Table: cd
ebf846e8 300--
eb0bc670 301CREATE TABLE cd (
302 cdid INTEGER PRIMARY KEY NOT NULL,
303 artist integer NOT NULL,
304 title varchar(100) NOT NULL,
305 year varchar(100) NOT NULL,
306 genreid integer,
307 single_track integer
308);
309
310CREATE INDEX cd_idx_artist ON cd (artist);
311
312CREATE INDEX cd_idx_genreid ON cd (genreid);
313
314CREATE INDEX cd_idx_single_track ON cd (single_track);
315
316CREATE UNIQUE INDEX cd_artist_title ON cd (artist, title);
317
318--
319-- Table: collection_object
320--
321CREATE TABLE collection_object (
322 collection integer NOT NULL,
323 object integer NOT NULL,
324 PRIMARY KEY (collection, object)
325);
326
327CREATE INDEX collection_object_idx_collection ON collection_object (collection);
328
329CREATE INDEX collection_object_idx_object ON collection_object (object);
330
331--
332-- Table: lyrics
333--
334CREATE TABLE lyrics (
335 lyric_id INTEGER PRIMARY KEY NOT NULL,
336 track_id integer NOT NULL
337);
338
339CREATE INDEX lyrics_idx_track_id ON lyrics (track_id);
340
341--
342-- Table: cd_artwork
343--
344CREATE TABLE cd_artwork (
345 cd_id INTEGER PRIMARY KEY NOT NULL
346);
347
eb0bc670 348--
349-- Table: liner_notes
350--
351CREATE TABLE liner_notes (
352 liner_id INTEGER PRIMARY KEY NOT NULL,
353 notes varchar(100) NOT NULL
354);
355
eb0bc670 356--
357-- Table: lyric_versions
358--
359CREATE TABLE lyric_versions (
78060df8 360 id INTEGER PRIMARY KEY NOT NULL,
eb0bc670 361 lyric_id integer NOT NULL,
362 text varchar(100) NOT NULL
ebf846e8 363);
364
eb0bc670 365CREATE INDEX lyric_versions_idx_lyric_id ON lyric_versions (lyric_id);
ebf846e8 366
367--
eb0bc670 368-- Table: tags
ebf846e8 369--
eb0bc670 370CREATE TABLE tags (
371 tagid INTEGER PRIMARY KEY NOT NULL,
372 cd integer NOT NULL,
373 tag varchar(100) NOT NULL
374);
375
376CREATE INDEX tags_idx_cd ON tags (cd);
377
378--
379-- Table: cd_to_producer
380--
381CREATE TABLE cd_to_producer (
382 cd integer NOT NULL,
383 producer integer NOT NULL,
384 attribute integer,
385 PRIMARY KEY (cd, producer)
ebf846e8 386);
387
eb0bc670 388CREATE INDEX cd_to_producer_idx_cd ON cd_to_producer (cd);
389
390CREATE INDEX cd_to_producer_idx_producer ON cd_to_producer (producer);
391
392--
393-- Table: images
394--
395CREATE TABLE images (
396 id INTEGER PRIMARY KEY NOT NULL,
397 artwork_id integer NOT NULL,
398 name varchar(100) NOT NULL,
399 data blob
400);
084a2c0a 401
eb0bc670 402CREATE INDEX images_idx_artwork_id ON images (artwork_id);
ebf846e8 403
404--
405-- Table: twokeys
406--
407CREATE TABLE twokeys (
408 artist integer NOT NULL,
409 cd integer NOT NULL,
410 PRIMARY KEY (artist, cd)
411);
412
eb0bc670 413CREATE INDEX twokeys_idx_artist ON twokeys (artist);
ebf846e8 414
415--
eb0bc670 416-- Table: artwork_to_artist
ebf846e8 417--
eb0bc670 418CREATE TABLE artwork_to_artist (
419 artwork_cd_id integer NOT NULL,
420 artist_id integer NOT NULL,
421 PRIMARY KEY (artwork_cd_id, artist_id)
78060df8 422);
423
eb0bc670 424CREATE INDEX artwork_to_artist_idx_artist_id ON artwork_to_artist (artist_id);
425
426CREATE INDEX artwork_to_artist_idx_artwork_cd_id ON artwork_to_artist (artwork_cd_id);
427
428--
429-- Table: fourkeys_to_twokeys
430--
431CREATE TABLE fourkeys_to_twokeys (
432 f_foo integer NOT NULL,
433 f_bar integer NOT NULL,
434 f_hello integer NOT NULL,
435 f_goodbye integer NOT NULL,
436 t_artist integer NOT NULL,
437 t_cd integer NOT NULL,
438 autopilot character NOT NULL,
439 pilot_sequence integer,
440 PRIMARY KEY (f_foo, f_bar, f_hello, f_goodbye, t_artist, t_cd)
441);
442
443CREATE INDEX fourkeys_to_twokeys_idx_f_foo_f_bar_f_hello_f_goodbye ON fourkeys_to_twokeys (f_foo, f_bar, f_hello, f_goodbye);
444
445CREATE INDEX fourkeys_to_twokeys_idx_t_artist_t_cd ON fourkeys_to_twokeys (t_artist, t_cd);
446
0e80c4ca 447--
084a2c0a 448-- View: year2000cds
0e80c4ca 449--
084a2c0a 450CREATE VIEW year2000cds AS
181b2261 451 SELECT cdid, artist, title, year, genreid, single_track FROM cd WHERE year = "2000"