fedilogue/tables.sql

47 lines
1.4 KiB
MySQL
Raw Normal View History

DROP TABLE IF EXISTS activities CASCADE;
DROP TABLE IF EXISTS actors CASCADE;
DROP TABLE IF EXISTS instances CASCADE;
CREATE TABLE actors (
2021-01-05 05:54:27 +00:00
actor_type VARCHAR(1000) NOT NULL,
2021-01-06 02:43:41 +00:00
id VARCHAR(2083) NOT NULL PRIMARY KEY UNIQUE,
2021-01-05 05:54:27 +00:00
inbox VARCHAR(2083) NOT NULL,
outbox VARCHAR(2083) NOT NULL,
followers VARCHAR(2083) NOT NULL,
following VARCHAR(2083) NOT NULL,
url VARCHAR(2083) NOT NULL,
preferredusername VARCHAR(1000) NOT NULL,
name VARCHAR(1000) NOT NULL,
summary TEXT,
icon VARCHAR(2083),
image VARCHAR(2083),
publickey TEXT,
identifiedat TIMESTAMP with time zone DEFAULT now(),
instance VARCHAR(1000) NOT NULL
);
CREATE TABLE activities (
2021-01-06 02:43:41 +00:00
id VARCHAR(2083) NOT NULL PRIMARY KEY UNIQUE,
2021-01-05 05:54:27 +00:00
inreplyto VARCHAR(2083),
published TIMESTAMP with time zone NOT NULL,
summary TEXT,
content TEXT,
normalized TEXT,
attributedto VARCHAR(2083) REFERENCES actors,
2021-01-05 05:54:27 +00:00
received_at TIMESTAMP with time zone DEFAULT now(),
instance VARCHAR(1000) NOT NULL
);
CREATE TABLE instances (
2021-01-06 02:43:41 +00:00
endpoint VARCHAR(2083) NOT NULL PRIMARY KEY UNIQUE,
2021-01-05 05:54:27 +00:00
autostart BOOLEAN,
state VARCHAR(16),
username VARCHAR(32),
password VARCHAR(32),
software VARCHAR(50)
);
ALTER TABLE activities ADD COLUMN normalized_idx tsvector;
UPDATE activities SET normalized_idx = to_tsvector('english', normalized);
CREATE INDEX ON activities USING gin(normalized_idx);