From 7ae2b2bb18685d757bbcca6c9e664170f1866486 Mon Sep 17 00:00:00 2001
From: Rob Austein <sra@hactrn.net>
Date: Thu, 17 Jul 2014 17:26:12 +0000
Subject: Start unwinding the twisty maze of method calls in the old
 publication code.

svn path=/branches/tk705/; revision=5898
---
 schemas/sql/pubd.sql | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)

(limited to 'schemas/sql/pubd.sql')

diff --git a/schemas/sql/pubd.sql b/schemas/sql/pubd.sql
index 210396d5..1264b82a 100644
--- a/schemas/sql/pubd.sql
+++ b/schemas/sql/pubd.sql
@@ -19,18 +19,19 @@
 
 -- SQL objects needed by pubd.py.
 
+-- Old tables that should just be flushed if present at all.
+
+DROP TABLE IF EXISTS config;
+DROP TABLE IF EXISTS snapshot;
+
 -- DROP TABLE commands must be in correct (reverse dependency) order
 -- to satisfy FOREIGN KEY constraints.
 
 DROP TABLE IF EXISTS object;
-DROP TABLE IF EXISTS snapshot;
+DROP TABLE IF EXISTS delta;
 DROP TABLE IF EXISTS session;
 DROP TABLE IF EXISTS client;
 
--- An old table that should just be flushed if present at all.
-
-DROP TABLE IF EXISTS config;
-
 CREATE TABLE client (
         client_id               SERIAL NOT NULL,
         client_handle           VARCHAR(255) NOT NULL,
@@ -45,17 +46,22 @@ CREATE TABLE client (
 CREATE TABLE session (
         session_id              SERIAL NOT NULL,
         uuid                    VARCHAR(36) NOT NULL,
+        serial                  BIGINT UNSIGNED NOT NULL,
+        snapshot                TEXT,
+        hash                    CHAR(64),
         PRIMARY KEY             (session_id),
         UNIQUE                  (uuid)
 ) ENGINE=InnoDB;
 
-CREATE TABLE snapshot (
-        snapshot_id             SERIAL NOT NULL,
-        activated               DATETIME,
-        expires                 DATETIME,
+CREATE TABLE delta (
+        delta_id                SERIAL NOT NULL,
+        serial                  BIGINT UNSIGNED NOT NULL,
+        xml                     TEXT NOT NULL,
+        hash                    CHAR(64) NOT NULL,
+        expires                 DATETIME NOT NULL,
         session_id              BIGINT UNSIGNED NOT NULL,
-        PRIMARY KEY             (snapshot_id),
-        CONSTRAINT              snapshot_session_id
+        PRIMARY KEY             (delta_id),
+        CONSTRAINT              delta_session_id
         FOREIGN KEY             (session_id) REFERENCES session (session_id) ON DELETE CASCADE
 ) ENGINE=InnoDB;
 
@@ -64,15 +70,9 @@ CREATE TABLE object (
         uri                     VARCHAR(255) NOT NULL,
         hash                    CHAR(64) NOT NULL,
         payload                 LONGBLOB NOT NULL,
-        published_snapshot_id   BIGINT UNSIGNED,
-        withdrawn_snapshot_id   BIGINT UNSIGNED,
         client_id               BIGINT UNSIGNED NOT NULL,
         session_id              BIGINT UNSIGNED NOT NULL,
         PRIMARY KEY             (object_id),
-        CONSTRAINT              object_published_snapshot_id
-        FOREIGN KEY             (published_snapshot_id) REFERENCES snapshot (snapshot_id) ON DELETE SET NULL,
-        CONSTRAINT              object_withdrawn_snapshot_id
-        FOREIGN KEY             (withdrawn_snapshot_id) REFERENCES snapshot (snapshot_id) ON DELETE CASCADE,
         CONSTRAINT              object_client_id
         FOREIGN KEY             (client_id) REFERENCES client (client_id) ON DELETE CASCADE,
         CONSTRAINT              object_session_id
-- 
cgit v1.2.3

