Return the database url used for connecting to the primary database. This is
provided by the Fly.io platform when you have attached to a PostgreSQL
database. Stored as an ENV called DATABASE_URL
.
Fly.Postgres (Fly Postgres v0.1.6) View Source
Help Elixir applications more easily take advantage of distributed Elixir applications using Ecto and PostgreSQL in a primary/replica configuration on Fly.io.
Link to this section Summary
Functions
Compute the database url to use for this app given the current configuration and runtime environment.
Returns the Repo module used by the application that is not the wrapped version. Used for making direct writable calls.
Function used to make the repository be read-only and error when creates, updates, or deletes are attempted. This behaves like a read-only replica which is helpful when modelling that setup locally in a dev environment.
Return the database url used for connecting to the primary database. This is
provided by the Fly.io platform when you have attached to a PostgreSQL
database. Stored as an ENV called DATABASE_URL
.
Return a database url used for connecting to a replica database. This makes the assumption that there is a replica running in the region where the app instance is running.
Execute the MFA (Module, Function, Arguments) on a node in the primary region. This presumes the primary region has direct access to a writable primary Postgres database. This waits for the data to be replicated to the current node before continuing on.
Link to this section Functions
Compute the database url to use for this app given the current configuration and runtime environment.
Returns the Repo module used by the application that is not the wrapped version. Used for making direct writable calls.
Example
Requires using application to configure.
# Configure database repository
config :fly_postgres, :local_repo, MyApp.Repo.Local
Specs
make_connection_read_only!(DBConnection.t()) :: :ok | no_return()
Function used to make the repository be read-only and error when creates, updates, or deletes are attempted. This behaves like a read-only replica which is helpful when modelling that setup locally in a dev environment.
Example
In your config/dev.exs
,
# Configure your database
config :my_app, MyApp.Repo.Local,
username: "postgres",
password: "postgres",
database: "my_db_dev",
hostname: "localhost",
show_sensitive_data_on_connection_error: true,
# Forcing the repo to be R/O locally for dev testing
after_connect: {Fly, :make_connection_read_only!, []},
pool_size: 10
Return a database url used for connecting to a replica database. This makes the assumption that there is a replica running in the region where the app instance is running.
Execute the MFA (Module, Function, Arguments) on a node in the primary region. This presumes the primary region has direct access to a writable primary Postgres database. This waits for the data to be replicated to the current node before continuing on.