Domain-Related Database Changes

This document describes changes to the database from version 1.0 to 2.0 to support Domains.

The 1.0 Database Schema:

CREATE TABLE CloudAuth( username, password );
CREATE TABLE CloudChanges( key, time, idx, op, line, user );
CREATE TABLE CloudConfig ( key, value );
CREATE TABLE CloudHtml( key, html );
CREATE TABLE CloudNodes (
    key, content, creation, creator, modification, modifier
);
CREATE TABLE CloudReferences ( src, dest );
CREATE UNIQUE INDEX CloudAuth_username ON CloudAuth( username );
CREATE INDEX CloudChanges_idx ON CloudChanges( idx );
CREATE INDEX CloudChanges_key ON CloudChanges( key );
CREATE INDEX CloudChanges_time ON CloudChanges( time );
CREATE UNIQUE INDEX CloudConfig_key ON CloudConfig( key );
CREATE UNIQUE INDEX CloudHtml_key ON CloudHtml( key );
CREATE INDEX CloudNodes_creation ON CloudNodes( creation );
CREATE UNIQUE INDEX CloudNodes_key ON CloudNodes( key );
CREATE INDEX CloudNodes_modification ON CloudNodes( modification );
CREATE INDEX CloudReferences_dest ON CloudReferences( dest );
CREATE INDEX CloudReferences_src ON CloudReferences( src );

The 2.0 Database Schema:

CREATE TABLE CloudAuth( username, password );
CREATE TABLE CloudChanges( domain, topic, time, idx, op, line, user );
CREATE TABLE CloudConfig ( key, value );
CREATE TABLE CloudHtml( domain, topic, html );
CREATE TABLE CloudNodes (
    domain, topic, content, creation, creator, modification, modifier
);
CREATE TABLE CloudReferences ( srcdomain, srctopic, dstdomain, dsttopic );
CREATE TABLE CloudSessions( token, username, touched );
CREATE UNIQUE INDEX CloudAuth_username ON CloudAuth( username );
CREATE INDEX CloudChanges_idx ON CloudChanges( idx );
CREATE INDEX CloudChanges_dt ON CloudChanges( domain, topic );
CREATE INDEX CloudChanges_time ON CloudChanges( time );
CREATE UNIQUE INDEX CloudConfig_key ON CloudConfig( key );
CREATE UNIQUE INDEX CloudHtml_dt ON CloudHtml( domain, topic );
CREATE INDEX CloudNodes_creation ON CloudNodes( creation );
CREATE UNIQUE INDEX CloudNodes_dt ON CloudNodes( domain, topic );
CREATE INDEX CloudNodes_modification ON CloudNodes( modification );
CREATE INDEX CloudReferences_dst ON CloudReferences( dstdomain, srctopic );
CREATE INDEX CloudReferences_src ON CloudReferences( srcdomain, srctopic );
CREATE UNIQUE INDEX CloudSessions_token ON CloudSessions( token );
CREATE UNIQUE INDEX CloudSessions_username ON CloudSessions( username );

Annotated Explanations of Changes:

CREATE TABLE CloudNodes (
    domain, topic, content, creation, creator, modification, modifier
);
CREATE UNIQUE INDEX CloudNodes_dt ON CloudNodes( domain, topic );

All nodes will be referred to by a pair of domain and topic in the database. Existing nodes will migrate their key column to topic, and their domain will be set to ":default:". The ":default:" site title corresponds with the site-name when rendered to html, and when parsed from content updates.

CREATE TABLE CloudChanges( domain, topic, time, idx, op, line, user );
CREATE INDEX CloudChanges_dt ON CloudChanges( domain, topic );

As with Change 1, all nodes must be referred to by a pair of domain and topic, now. Migration is the same, here.

CREATE TABLE CloudHtml( domain, topic, html );
CREATE UNIQUE INDEX CloudHtml_dt ON CloudHtml( domain, topic );

As with Change 1, all nodes must be referred to by a pair of domain and topic, migration is identical.

CREATE TABLE CloudReferences ( srcdomain, srctopic, dstdomain, dsttopic );
CREATE INDEX CloudReferences_dst ON CloudReferences( dstdomain, srctopic );
CREATE INDEX CloudReferences_src ON CloudReferences( srcdomain, srctopic );

As with Change 1, all nodes must be referred to by a pair of domain and topic, migration of src is to srctopic, dest to dsttopic (note the loss of an 'e'), and both srcdomain and dstdomain will be set to ":default:".