2021-02-01 12:52:42 +00:00
|
|
|
DROP TABLE IF EXISTS activities CASCADE;
|
|
|
|
DROP TABLE IF EXISTS actors CASCADE;
|
|
|
|
DROP TABLE IF EXISTS instances CASCADE;
|
2020-10-29 15:06:45 +00:00
|
|
|
|
2021-02-01 12:52:42 +00:00
|
|
|
CREATE TABLE actors (
|
2021-02-01 20:31:40 +00:00
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
document JSONB,
|
2021-01-05 05:54:27 +00:00
|
|
|
identifiedat TIMESTAMP with time zone DEFAULT now(),
|
|
|
|
instance VARCHAR(1000) NOT NULL
|
2020-10-28 20:49:11 +00:00
|
|
|
);
|
|
|
|
|
2021-02-01 20:31:40 +00:00
|
|
|
CREATE UNIQUE INDEX actors_uri ON actors ( (document->'id') );
|
|
|
|
|
2021-02-01 12:52:42 +00:00
|
|
|
CREATE TABLE activities (
|
2021-02-01 20:31:40 +00:00
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
document JSONB,
|
2021-01-05 05:54:27 +00:00
|
|
|
normalized TEXT,
|
|
|
|
instance VARCHAR(1000) NOT NULL
|
|
|
|
);
|
|
|
|
|
2021-02-01 20:31:40 +00:00
|
|
|
CREATE UNIQUE INDEX activities_uri ON activities ( (document->'id') );
|
|
|
|
|
2021-01-05 05:54:27 +00:00
|
|
|
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)
|
2020-10-28 20:49:11 +00:00
|
|
|
);
|
2021-02-01 12:52:42 +00:00
|
|
|
|
2021-02-03 01:28:27 +00:00
|
|
|
-- ALTER TABLE activities ADD COLUMN normalized_tsvector tsvector;
|
|
|
|
-- UPDATE activities SET normalized_tsvector = to_tsvector('english', normalized);
|
|
|
|
|
|
|
|
ALTER TABLE activities
|
|
|
|
ADD normalized_tsvector tsvector
|
|
|
|
GENERATED ALWAYS AS (to_tsvector('english', normalized)) STORED;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CREATE INDEX normalized_idx ON activities USING gin(normalized_tsvector);
|
2021-02-01 20:31:40 +00:00
|
|
|
|
|
|
|
CREATE INDEX actors_id_idx ON actors (id);
|
|
|
|
CREATE INDEX activities_id_idx ON activities (id);
|
|
|
|
CREATE INDEX actors_uri_idx ON actors ( (document->'id') );
|
|
|
|
CREATE INDEX activities_uri_idx ON activities ( (document->'id') );
|