 \c haskell_tools
 CREATE EXTENSION unaccent;
 CREATE EXTENSION pg_trgm;
+CREATE SCHEMA private;
 -- Private data structures
 
-CREATE TABLE public.packages (
+CREATE TABLE private.packages (
   package_name text PRIMARY KEY,
   version text NOT NULL,
   license text NOT NULL,

  updated_at timestamp NOT NULL default current_timestamp
);

CREATE TABLE public.dependencies (
  dependent text REFERENCES public.packages (package_name),
  dependency text REFERENCES public.packages (package_name),
  version_range text,
  created_at timestamp NOT NULL default current_timestamp,
  updated_at timestamp NOT NULL default current_timestamp,
  PRIMARY KEY (dependent, dependency)
);

CREATE TABLE public.extensions (
  package_name text REFERENCES public.packages (package_name),
  extension text,
  created_at timestamp NOT NULL default current_timestamp,
  updated_at timestamp NOT NULL default current_timestamp,

  -- when querying updated at we usually want to know when it was last updated
  GREATEST(p.updated_at, r.updated_at) as updated_at
FROM
  private.packages p
  JOIN private.repos r USING (package_name)
GROUP BY
  p.package_name, r.package_name;

CREATE OR REPLACE FUNCTION public.package_search(query text)
   RETURNS SETOF public.packages
   LANGUAGE sql
   STABLE
  AS $function$
  SELECT
      p.*
  FROM
      public.packages p
  WHERE
      to_tsvector(p.description) @@ plainto_tsquery(unaccent(query))
      OR
