From 21f87779a3cffe387f181f263d2efa38c1024c49 Mon Sep 17 00:00:00 2001 From: Chris Bailey Date: Wed, 17 Jan 2024 12:37:27 +0000 Subject: [PATCH] END-013 - Add documentation --- lib/endo.ex | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/lib/endo.ex b/lib/endo.ex index 1fb19f7..d8ef3dd 100644 --- a/lib/endo.ex +++ b/lib/endo.ex @@ -139,6 +139,29 @@ defmodule Endo do As features get built out, we make no hard guarantees of keeping the `metadata` field stable, but efforts will of course be taken to mitigate unnecessary breaking changes from occuring. + + ## Setting schema prefixes / table schemas + + By default, Endo will assume that your application's tables are stored in the `public` schema. This is the + default schema for Postgres, but it is possible to change this by setting the `:table_schema` config option + in your application's config like so: + + ```elixir + config :endo, table_schema: "custom_schema" + ``` + + If set this way, Endo will use the given schema as the default schema for all queries. This can be overridden + on a per-query basis by passing the `:prefix` option to `Endo.list_tables/2` or `Endo.get_table/3` mimicing + the behavior of the `:prefix` option in `Ecto`: + + ```elixir + [%Endo.Table{}, ...] = Endo.list_tables(MyApp.Repo, prefix: "custom_schema") + %Endo.Table{} = Endo.get_table(MyApp.Repo, "special_table", prefix: "custom_schema") + ``` + + Additionally, Endo will display the table schema of any given table via `%Endo.Table{schema: schema}`. + + For runtime debugging, you can use the `Endo.table_schema/0` function to retrieve the current default schema. """ alias Endo.Adapters.Postgres