Add UNIQUE constraints on db
This commit is contained in:
parent
43078b9f9e
commit
aafaa8648f
@ -292,7 +292,7 @@ int main(int argc, char** argv) {
|
|||||||
amplitude REAL, \
|
amplitude REAL, \
|
||||||
frequency REAL, \
|
frequency REAL, \
|
||||||
attack REAL, \
|
attack REAL, \
|
||||||
filename TEXT)",
|
filename TEXT UNIQUE)",
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
if (SQLITE_OK != dberr) {
|
if (SQLITE_OK != dberr) {
|
||||||
fprintf(stderr, "Error creating db: %s.\n", sqlite3_errmsg(dbh));
|
fprintf(stderr, "Error creating db: %s.\n", sqlite3_errmsg(dbh));
|
||||||
@ -304,7 +304,8 @@ int main(int argc, char** argv) {
|
|||||||
song2 INTEGER, \
|
song2 INTEGER, \
|
||||||
distance REAL, \
|
distance REAL, \
|
||||||
FOREIGN KEY(song1) REFERENCES songs(id) ON DELETE CASCADE, \
|
FOREIGN KEY(song1) REFERENCES songs(id) ON DELETE CASCADE, \
|
||||||
FOREIGN KEY(song2) REFERENCES songs(id) ON DELETE CASCADE)",
|
FOREIGN KEY(song2) REFERENCES songs(id) ON DELETE CASCADE, \
|
||||||
|
UNIQUE (song1, song2))",
|
||||||
NULL, NULL, NULL);
|
NULL, NULL, NULL);
|
||||||
if (SQLITE_OK != dberr) {
|
if (SQLITE_OK != dberr) {
|
||||||
fprintf(stderr, "Error creating db: %s.\n", sqlite3_errmsg(dbh));
|
fprintf(stderr, "Error creating db: %s.\n", sqlite3_errmsg(dbh));
|
||||||
|
Loading…
Reference in New Issue
Block a user