Extend local database once more.
[cumulus.git] / schema.sql
index 114670c..d225ec1 100644 (file)
@@ -3,12 +3,36 @@
 --
 -- The index is stored in an SQLite3 database.  This is its schema.
 
--- Index of all blocks which have been stored in one snapshot, by checksum.
+-- List of snapshots which have been created.
+create table snapshots (
+    snapshotid integer primary key,
+    name text not null,
+    timestamp real
+);
+
+-- List of segments which have been created.
+create table segments (
+    segmentid integer primary key,
+    segment text unique not null
+);
+
+-- Index of all blocks which have been stored in a snapshot, by checksum.
 create table block_index (
     blockid integer primary key,
-    segment text,
-    object text,
+    segmentid integer not null,
+    object text not null,
     checksum text,
-    size integer
+    size integer,
+    timestamp real,
+    expired integer
 );
 create index block_content_index on block_index(checksum);
+create unique index block_name_index on block_index(segmentid, object);
+
+-- Index tracking which blocks are used by which snapshots.
+create table snapshot_contents (
+    blockid integer,
+    snapshotid integer
+);
+create unique index snapshot_contents_unique
+    on snapshot_contents(blockid, snapshotid);