added table relationship

This commit is contained in:
farhan 2021-01-05 05:54:27 +00:00
parent 81b06d64e8
commit 5ea270f9ec

View File

@ -1,47 +1,43 @@
DROP TABLE instances; DROP TABLE IF EXISTS instances;
DROP TABLE accounts; DROP TABLE IF EXISTS posts;
DROP TABLE posts; DROP TABLE IF EXISTS accounts;
CREATE TABLE accounts ( CREATE TABLE accounts (
key serial NOT NULL, actor_type VARCHAR(1000) NOT NULL,
actor_type character varying(1000) NOT NULL, id VARCHAR(2083) NOT NULL PRIMARY KEY,
id character varying(2083) NOT NULL PRIMARY KEY, inbox VARCHAR(2083) NOT NULL,
inbox character varying(2083) NOT NULL, outbox VARCHAR(2083) NOT NULL,
outbox character varying(2083) NOT NULL, followers VARCHAR(2083) NOT NULL,
followers character varying(2083) NOT NULL, following VARCHAR(2083) NOT NULL,
following character varying(2083) NOT NULL, url VARCHAR(2083) NOT NULL,
url character varying(2083) NOT NULL, preferredusername VARCHAR(1000) NOT NULL,
preferredusername character varying(1000) NOT NULL, name VARCHAR(1000) NOT NULL,
name character varying(1000) NOT NULL, summary TEXT,
summary text, icon VARCHAR(2083),
icon character varying(2083), image VARCHAR(2083),
image character varying(2083), publickey TEXT,
publickey text, identifiedat TIMESTAMP with time zone DEFAULT now(),
identifiedat timestamp with time zone DEFAULT now(), instance VARCHAR(1000) NOT NULL
instance character varying(1000) NOT NULL );
CREATE TABLE posts (
id VARCHAR(2083) NOT NULL,
inreplyto VARCHAR(2083),
published TIMESTAMP with time zone NOT NULL,
summary TEXT,
content TEXT,
normalized TEXT,
attributedto VARCHAR(2083) REFERENCES accounts,
posthash bytea,
received_at TIMESTAMP with time zone DEFAULT now(),
instance VARCHAR(1000) NOT NULL
); );
CREATE TABLE instances ( CREATE TABLE instances (
id integer NOT NULL, endpoint VARCHAR(2083) NOT NULL,
endpoint character varying(2083) NOT NULL, autostart BOOLEAN,
autostart boolean, state VARCHAR(16),
state character varying(16), username VARCHAR(32),
username character varying(32), password VARCHAR(32),
password character varying(32), software VARCHAR(50)
software character varying(50)
);
CREATE TABLE posts (
key serial NOT NULL,
id character varying(2083) NOT NULL PRIMARY KEY,
inreplyto character varying(2083),
published timestamp with time zone NOT NULL,
summary text,
content text,
normalized text,
attributedto character varying(1000) NOT NULL,
posthash bytea,
received_at timestamp with time zone DEFAULT now(),
instance character varying(1000) NOT NULL
); );