CREATE TABLE domain (
	id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
	hostname text NOT NULL,
	authoritative boolean NOT NULL,
	tags text[] NOT NULL,
	last_index_date timestamptz,
	crawl_duration interval
);

CREATE TABLE page (
	id integer PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
	domain_id integer NOT NULL REFERENCES domain(id),
	url text NOT NULL UNIQUE,
	weight integer NOT NULL,
	checksum bytea NOT NULL UNIQUE,
	last_index_date timestamptz NOT NULL,
	crawl_priority integer NOT NULL,
	crawl_delay interval,
	fts_vector tsvector NOT NULL,
	javascript boolean NOT NULL,
	title text,
	language text,
	description text,
	author text,
	excerpt text
);

CREATE INDEX idx_page_content ON page USING GIN (fts_vector);
