PostgreSQL Storage
The PostgreSQL storage plugin uses a PostgreSQL database to store the migration history (duh). In the same package you can find the PostgreSQL Loader and the PostgreSQL Generator.
Installation
Configuration
The PostgreSQL storage can be configured either using environment variables or by configuring the plugin directly in the emigrate.config.js
file.
Configuration file
Options
table
type: string
default: "migrations"
The name of the table to use for storing the migrations.
connection
(required)
type: object | string
The connection options to use for connecting to the PostgreSQL database. This can either be a connection URI or an object with connection options. For a list of supported connection options, see the postgres documentation.
Environment variables
The following environment variables are supported:
Variable | Description | Default |
---|---|---|
POSTGRES_TABLE | The name of the table to use for storing the migrations | "migrations" |
POSTGRES_URL | The full URI for connecting to a PostgreSQL database, e.g: "postgres://user:pass@127.0.0.1:3306/database" | |
POSTGRES_HOST | The host on which the PostgreSQL server instance is running | "localhost" |
POSTGRES_USER | The PostgreSQL user account to use for the authentication | |
POSTGRES_PASSWORD | The PostgreSQL user password to use for the authentication | |
POSTGRES_PORT | The network port on which the PostgreSQL server is listening | 5432 |
POSTGRES_DB | The PostgreSQL database to use for the connection |
The environment variables are used when the storage plugin is used using the --storage
command line option:
Or when specifying the storage in the emigrate.config.js
file as a string: