Use 'primary key' constraint instead of index

Signed-off-by: Alexis Sellier <alexis@radicle.xyz>
This commit is contained in:
Alexis Sellier 2022-10-19 22:33:57 +02:00
parent 706fbc6550
commit 2ec320acec
No known key found for this signature in database
2 changed files with 10 additions and 6 deletions

View File

@ -104,9 +104,15 @@ impl<R: Reactor> Client<R> {
let time = LocalTime::now();
let storage = self.profile.storage;
let signer = self.profile.signer;
let addresses =
address::Book::open(self.profile.home.join(NODE_DIR).join(ADDRESS_DB_FILE))?;
let routing = routing::Table::open(self.profile.home.join(NODE_DIR).join(ROUTING_DB_FILE))?;
let node_dir = self.profile.home.join(NODE_DIR);
let address_db = node_dir.join(ADDRESS_DB_FILE);
let routing_db = node_dir.join(ROUTING_DB_FILE);
log::info!("Opening address book {}..", address_db.display());
let addresses = address::Book::open(address_db)?;
log::info!("Opening routing table {}..", routing_db.display());
let routing = routing::Table::open(routing_db)?;
log::info!("Initializing client ({:?})..", network);

View File

@ -2,7 +2,6 @@
-- Routing table SQL schema.
--
create table if not exists "routing" (
"id" integer primary key,
-- Resource being seeded.
"resource" text not null,
-- Node ID.
@ -10,6 +9,5 @@ create table if not exists "routing" (
-- UNIX time at which this entry was added or refreshed.
"time" integer not null,
unique("resource", "node")
primary key ("resource", "node")
);
create index "routing_index" on routing ("resource", "node");