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