DROP TABLE instances;
DROP TABLE accounts;
DROP TABLE posts;

CREATE TABLE accounts (
    key serial NOT NULL,
    actor_type character varying(1000) NOT NULL,
    id character varying(2083) NOT NULL PRIMARY KEY,
    inbox character varying(2083) NOT NULL,
    outbox character varying(2083) NOT NULL,
    followers character varying(2083) NOT NULL,
    following character varying(2083) NOT NULL,
    url character varying(2083) NOT NULL,
    preferredusername character varying(1000) NOT NULL,
    name character varying(1000) NOT NULL,
    summary text,
    icon character varying(2083),
    image character varying(2083),
    publickey text,
    identifiedat timestamp with time zone DEFAULT now(),
    instance character varying(1000) NOT NULL
);

CREATE TABLE instances (
    id integer NOT NULL,
    endpoint character varying(2083) NOT NULL,
    autostart boolean,
    state character varying(16),
    username character varying(32),
    password character varying(32),
    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
);
