21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
from_weekday smallint DEFAULT 0 NOT NULL,
to_weekday smallint DEFAULT 6 NOT NULL,
from_time time without time zone DEFAULT '00:00:00'::time without time zone NOT NULL,
to_time time without time zone DEFAULT '23:59:59'::time without time zone NOT NULL,
tag text[] NOT NULL
);
-- table to hold tag - site links
CREATE TABLE urls (
date_added timestamp without time zone DEFAULT ('now'::text)::timestamp(0) without time zone NOT NULL,
site text[] NOT NULL,
tag text[] NOT NULL,
regexp text
);
create unique index urls_rst on urls (regexp, usort(site), usort(tag));
-- rule to join all tables into one to simplify access
-- automaticall uses current day and time data
create view site_rule as
select redirect_url, netmask, site, regexp
from rules join urls
|
>
>
>
>
|
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
from_weekday smallint DEFAULT 0 NOT NULL,
to_weekday smallint DEFAULT 6 NOT NULL,
from_time time without time zone DEFAULT '00:00:00'::time without time zone NOT NULL,
to_time time without time zone DEFAULT '23:59:59'::time without time zone NOT NULL,
tag text[] NOT NULL
);
create index rules_tag_g on rules using gin (tag);
-- table to hold tag - site links
CREATE TABLE urls (
date_added timestamp without time zone DEFAULT ('now'::text)::timestamp(0) without time zone NOT NULL,
site text[] NOT NULL,
tag text[] NOT NULL,
regexp text
);
create index urls_tag_g on urls using gin (tag);
create index urls_site_g on urls using gin (site);
create unique index urls_rst on urls (regexp, usort(site), usort(tag));
-- rule to join all tables into one to simplify access
-- automaticall uses current day and time data
create view site_rule as
select redirect_url, netmask, site, regexp
from rules join urls
|