Browse Source

db: Enable foreign keys and cascade on shachain delete

Should make maintenance a bit easier.
ppa-0.6.1
Christian Decker 8 years ago
committed by Rusty Russell
parent
commit
416d6bf860
  1. 6
      wallet/db.c

6
wallet/db.c

@ -31,7 +31,7 @@ char *dbmigrations[] = {
num_valid INTEGER, \
PRIMARY KEY (id));",
"CREATE TABLE shachain_known ( \
shachain_id INTEGER, \
shachain_id INTEGER REFERENCES shachains(id) ON DELETE CASCADE, \
pos INTEGER, \
idx INTEGER, \
hash BLOB, \
@ -155,6 +155,10 @@ static struct db *db_open(const tal_t *ctx, char *filename)
tal_add_destructor(db, close_db);
db->in_transaction = false;
db->err = NULL;
if (!db_exec(__func__, db, "PRAGMA foreign_keys = ON;")) {
fatal("Could not enable foreignkeys on database: %s", db->err);
}
return db;
}

Loading…
Cancel
Save