SET search_path = revision,public;

ALTER TABLE attributes ALTER COLUMN contents SET NOT NULL;


CREATE TABLE attributes_relations
(
    id bigint PRIMARY KEY REFERENCES revision.attributes (id),
    contents public.hstore NOT NULL
);

CREATE INDEX attributes_relations_gist_contents_idx ON attributes_relations USING gist (contents);
CREATE INDEX attributes_relations_btree_contents_idx ON attributes_relations USING btree (contents);


INSERT INTO attributes_relations SELECT * FROM attributes WHERE contents ? 'rel:role';
