CREATE TABLE "component_set_rule" (
  "component_name" VARCHAR(128) NOT NULL,
  "component_set_web_path" VARCHAR(128) NOT NULL REFERENCES "component_set" ("web_path") ON DELETE CASCADE,
  "version_pattern" VARCHAR(128) NOT NULL,

  CONSTRAINT "component_set_rule_pkey" PRIMARY KEY ("component_name", "component_set_web_path")
);

CREATE INDEX "component_set_rule_component_name" ON "component_set_rule" ( "component_name" );
CREATE INDEX "component_set_rule_component_set_web_path" ON "component_set_rule" ( "component_set_web_path" );


-- NOTE this does not require an update thanks to Postgres smarts:
-- > When a column is added with ADD COLUMN and a non-volatile DEFAULT is specified, 
-- > the default is evaluated at the time of the statement and the result stored in the table's metadata. 
-- > That value will be used for the column for all existing rows. If no DEFAULT is specified, NULL is used. 
-- > In neither case is a rewrite of the table required.
ALTER TABLE "component_set_component_version"
  ADD COLUMN "is_visible" BOOLEAN DEFAULT 'true';