SQL (sqlite) DB schema

This commit is contained in:
Vincent Riquer 2013-02-24 17:56:44 +01:00
parent 194c707172
commit 9ec54b012c

24
doc/schema.sql Normal file
View File

@ -0,0 +1,24 @@
BEGIN TRANSACTION;
CREATE TABLE source_files (
id INTEGER PRIMARY KEY,
filename TEXT UNIQUE COLLATE NOT NULL,
size INTEGER NOT NULL,
hash TEXT,
last_change INTEGER NOT NULL DEFAULT (strftime('%s','now'))
last_seen INTEGER NOT NULL DEFAULT (strftime('%s','now'))
);
CREATE TABLE destinations (
id INTEGER PRIMARY KEY,
path TEXT UNIQUE COLLATE NOT NULL
);
CREATE TABLE destination_files (
id INTEGER PRIMARY KEY,
filename TEXT UNIQUE COLLATE NOT NULL,
last_change INTEGER NOT NULL DEFAULT (strftime('%s','now')),
to_delete NOT NULL DEFAULT 0,
update_needed NOT NULL DEFAULT 1,
FOREIGN KEY(source_file) REFERENCES source_files(id),
FOREIGN KEY(destination) REFERENCES destinations(id)
);
COMMIT;