{
$self->create();
}
-
+ $self->enable_foreign_keys();
return $self;
}
}
}
+sub enable_foreign_keys
+{
+ my $self=shift;
+ $self->cmd("PRAGMA foreign_keys = ON");
+}
+
sub last_update
{
my($self, $newval)=@_;
last_update
);
-CREATE TABLE files (
- id INTEGER PRIMARY KEY,
- artists_id,
- albums_id,
- paths_id,
- name text
-);
-
CREATE TABLE paths (
id INTEGER PRIMARY KEY,
name text
name text
);
+CREATE TABLE files (
+ id INTEGER PRIMARY KEY,
+ artists_id,
+ albums_id,
+ paths_id,
+ name text,
+ FOREIGN KEY(artists_id) REFERENCES artists(id),
+ FOREIGN KEY(albums_id) REFERENCES albums(id),
+ FOREIGN KEY(paths_id) REFERENCES paths(id)
+);
+
CREATE TABLE tags (
id INTEGER PRIMARY KEY,
name text
CREATE TABLE files_x_tags (
files_id INTEGER,
- tags_id INTEGER
+ tags_id INTEGER,
+ FOREIGN KEY(files_id) REFERENCES files(id),
+ FOREIGN KEY(tags_id) REFERENCES tags(id)
);
CREATE TABLE tags_x_tagvals (
tags_id INTEGER,
- tagvals_id INTEGER
+ tagvals_id INTEGER,
+ FOREIGN KEY(tags_id) REFERENCES tags(id),
+ FOREIGN KEY(tagvals_id) REFERENCES tagvals(id)
);