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