Flippant.Adapter.Postgres (Flippant v2.0.0) View Source
This adapter provides Postgres 9.5+ backed rule storage.
The adapter relies on a table with the following structure:
name- Atextorvarcharcolumn with a unique constraint. The adapter makes heavy use ofUPSERTfunctionality, which relies on unique names.rules- Ajsonbcolumn where rules will be stored. The use of jsonb and jsonb specific operators means the Postgres version must be 9.5 or greater.
In the likely chance that you're managing a database using Ecto you can
create a migration to add the flippant_features table with the following
statement (or an equivalent):
CREATE TABLE IF NOT EXISTS flippant_features (
name varchar(140) NOT NULL CHECK (name <> ''),
rules jsonb NOT NULL DEFAULT '{}'::jsonb,
CONSTRAINT unique_name UNIQUE(name)
)If you prefer you can also use the adapters setup/0 function to create
the table automatically.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Callback implementation for GenServer.init/1.
Starts the Postgres adapter.
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Callback implementation for GenServer.init/1.
Starts the Postgres adapter.
Options
:postgres_opts- Options that can be passed to Postgrex, the underlying library used to connect to Postgres. At a minimum thedatabasemust be set, otherwise it will attempt to connect to theflippant_testdatabase.table- The table where rules will be stored. Defaults toflippant_features.