-- :name create-storage!
-- :command :execute
-- :result :raw
-- :doc creates the document storage tables and datatypes
CREATE SCHEMA IF NOT EXISTS :i:schema-name;
--;;
CREATE TABLE IF NOT EXISTS :i:repositories-table (
	id varchar(32) NOT NULL,
  caching bool NOT NULL DEFAULT FALSE,
	"versioning" bool NOT NULL DEFAULT TRUE,
	created_at timestamptz(0) NOT NULL DEFAULT CURRENT_TIMESTAMP,
	CONSTRAINT repositories_pk PRIMARY KEY (id));
--;;
DO $$DECLARE
  BEGIN
    CREATE TYPE
      :i:ds-type-fqn
      AS ENUM (
	      'keydiffcopydelete',
	      'key',
	      'diff',
	      'clone',
	      'delete');
EXCEPTION
  when others then
end $$;
--;;
DO $$DECLARE
  BEGIN
    CREATE TYPE
      :i:ds-encoding-fqn
      AS ENUM (
	      'transit+json',
	      'edn',
	      'nippy');
EXCEPTION
  when others then
end $$;