summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--db.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/db.c b/db.c
index c23fa3d..a3bcb34 100644
--- a/db.c
+++ b/db.c
@@ -21,7 +21,7 @@ static int db_create_tables() {
");"
"create table wallpaper ("
" id integer not null,"
- " dirid integer not null,"
+ " dirid integer not null references directory (id) on delete cascade,"
" date integer not null,"
" filepath text not null,"
" size integer not null,"
@@ -31,13 +31,13 @@ static int db_create_tables() {
");"
"create table tag ("
" id integer not null,"
- " parent integer null,"
+ " parent integer null references tag (id) on delete cascade,"
" name varchar(100) not null,"
" primary key (id)"
");"
"create table walltags ("
- " wallid integer not null,"
- " tagid integer not null,"
+ " wallid integer not null references wallpaper (id),"
+ " tagid integer not null references tag (id),"
" primary key (wallid, tagid)"
");",
NULL, NULL, &errmsg);
@@ -73,6 +73,8 @@ int db_open() {
return 0;
}
+ sqlite3_exec(db, "PRAGMA foreign_keys = ON;", NULL, NULL, NULL);
+
if(!datafound && !db_create_tables()) {
db_close();
return 0;