CREATE TABLE nodes (node TEXT NOT NULL PRIMARY KEY);
ALTER TABLE nodes OWNER TO "buddycloud-server";

CREATE TABLE node_config (node TEXT NOT NULL REFERENCES nodes (node),
       	     		  "key" TEXT,
			  "value" TEXT,
			  updated TIMESTAMP,
			  PRIMARY KEY (node, "key"));
ALTER TABLE node_config OWNER TO "buddycloud-server";

CREATE TABLE items (node TEXT REFERENCES nodes (node),
       	     	    id TEXT NOT NULL,
		    author TEXT,
		    updated TIMESTAMP,
		    xml TEXT,
		    PRIMARY KEY (node, id));
ALTER TABLE items OWNER TO "buddycloud-server";
CREATE INDEX items_updated ON items (updated);

CREATE TABLE subscriptions (node TEXT REFERENCES nodes (node),
       	     		    "user" TEXT,
			    listener TEXT,
			    subscription TEXT,
 			    updated TIMESTAMP,
			    PRIMARY KEY (node, "user"));
ALTER TABLE subscriptions OWNER TO "buddycloud-server";
CREATE INDEX subscriptions_updated ON subscriptions (updated);

CREATE TABLE affiliations (node TEXT REFERENCES nodes (node),
       	     		   "user" TEXT,
			   affiliation TEXT,
 			   updated TIMESTAMP,
			   PRIMARY KEY (node, "user"));
ALTER TABLE affiliations OWNER TO "buddycloud-server";
CREATE INDEX affiliations_updated ON affiliations (updated);


CREATE TABLE nodes (node TEXT NOT NULL PRIMARY KEY);
CREATE TABLE node_config (node TEXT NOT NULL REFERENCES nodes (node),
       	     		  "key" TEXT,
			  "value" TEXT,
			  updated TIMESTAMP,
			  PRIMARY KEY (node, "key"));
CREATE TABLE items (node TEXT REFERENCES nodes (node),
       	     	    id TEXT NOT NULL,
		    author TEXT,
		    updated TIMESTAMP,
		    xml TEXT,
		    PRIMARY KEY (node, id));
CREATE INDEX items_updated ON items (updated);
CREATE TABLE subscriptions (node TEXT REFERENCES nodes (node),
       	     		    "user" TEXT,
			    listener TEXT,
			    subscription TEXT,
 			    updated TIMESTAMP,
			    PRIMARY KEY (node, "user"));
CREATE INDEX subscriptions_updated ON subscriptions (updated);
CREATE TABLE affiliations (node TEXT REFERENCES nodes (node),
       	     		   "user" TEXT,
			   affiliation TEXT,
 			   updated TIMESTAMP,
			   PRIMARY KEY (node, "user"));
CREATE INDEX affiliations_updated ON affiliations (updated);


Revert "Made the ownership of tables really clear. Should help avoid the problem that DD had the other day."
Revert "Made the ownership of tables really clear. Should help avoid the problem that DD had the other day."

This reverts commit e1144cf9ba61e87df9ee4c4bd0889e7a4422ee2c.

That commit introduced a hard-coded username in multiple places in a source
code file instead of just in the config. When creating the database according
to the Wiki instructions these changes are unneeded.
