test-fk.sql 1.44 KB
Newer Older
1
2
use tank;

3
/* should succeed */
4
insert into shows (name) values ('test');
5
6
7

/* should fail */
insert into files (size) values(100);
8
insert into files (show_name, size) values('invalid', 101);
9
10

/* should succeed */
11
12
insert into files (show_name, size) values('test', 101);
insert into files (show_name, size) values('test', 102);
13
14
15
16
select * from files;


/* should fail */
17
insert into playlists (created_at) values ('2018-06-17 02:38:17');
18
19

/* should succeed */
20
insert into playlists (created_at, show_name) values('2018-06-17 02:38:17', 'test');
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44


/* should fail */
insert into playlist_entries (uri) values ('http://stream.example.com/live.mp3');
insert into playlist_entries (playlist_id, uri) values (1, 'http://stream.example.com/live.mp3');
insert into playlist_entries (playlist_id, line_num, uri) values (17, 1, 'http://stream.example.com/live.mp3');

/* should succeed */
insert into playlist_entries (playlist_id, line_num, uri) values (1, 1, 'http://stream.example.com/live.mp3');

/* should fail */
insert into playlist_entries (playlist_id, line_num, uri) values (1, 1, 'http://stream.example.com/other.mp3');
insert into playlist_entries (playlist_id, line_num, file_id) values (1, 4, 23);

/* should succeed */
insert into playlist_entries (playlist_id, line_num, file_id) values (1, 4, 2);
delete from files where id = 1;

/* should fail */
delete from files where id = 2;

/* should succeed */
delete from playlists where id = 1;
delete from files where id = 2;