DO $$
BEGIN
  IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'cms_tag_kind') THEN
    RAISE EXCEPTION 'missing type: cms_tag_kind';
  END IF;
  IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'cms_article_status') THEN
    RAISE EXCEPTION 'missing type: cms_article_status';
  END IF;

  IF to_regclass('public.cms_columns') IS NULL THEN
    RAISE EXCEPTION 'missing table: cms_columns';
  END IF;
  IF to_regclass('public.cms_tags') IS NULL THEN
    RAISE EXCEPTION 'missing table: cms_tags';
  END IF;
  IF to_regclass('public.cms_media') IS NULL THEN
    RAISE EXCEPTION 'missing table: cms_media';
  END IF;
  IF to_regclass('public.cms_articles') IS NULL THEN
    RAISE EXCEPTION 'missing table: cms_articles';
  END IF;
  IF to_regclass('public.cms_article_tags') IS NULL THEN
    RAISE EXCEPTION 'missing table: cms_article_tags';
  END IF;
  IF to_regclass('public.cms_article_versions') IS NULL THEN
    RAISE EXCEPTION 'missing table: cms_article_versions';
  END IF;
END $$;

