Configuration¶
Configuration files¶
ElasticMigrate reads config.json files from three places, in this order:
the user configuration directory, for example
~/.config/elastic-migrate/config.jsonon Linux;config.jsonin the current working directory;the file named by the
ESMIGRATE_CONFIGenvironment variable.
Each file holds a list of named profiles. When the same profile appears in several files, its fields are merged and
later files win field by field. Files that are missing, unreadable or not a JSON object are skipped. A profile that is
not found in any file fails with exit code 10.
{
"profiles": [
{
"default": {
"elastic_host": "http://localhost:9200",
"schema_db": "sqlite:///esmigrate.db",
"schema_dir": "./migrations"
}
},
{
"production": {
"elastic_host": "https://es.example.com:9200",
"elastic_api_key": "${ESMIGRATE_ES_API_KEY}",
"schema_db": "postgresql://migrator:${ESMIGRATE_DB_PASSWORD}@db.example.com/platform",
"schema_db_schema": "search_migrations",
"schema_dir": "./migrations",
"log_file": "/var/log/esmigrate/esmigrate.log"
}
}
]
}
Select a profile with -p/--profile; the default profile is called default.
esmigrate -p production upgrade
Environment variables in values¶
Any string value, including values inside elastic_headers, may reference environment variables as ${NAME}. This
keeps secrets and per-environment values out of config.json. A reference to a variable that is not set fails with
exit code 11 and names the variable and the field; it never turns into an empty string.
Profile fields¶
schema_dir is required; every other field is optional. Invalid values fail when the profile is loaded, with exit code
11.
Field |
Default |
Description |
|---|---|---|
|
(required) |
Directory containing the migration scripts. |
|
|
Script file extension. |
|
|
SQLAlchemy URL of the schema version database. See Schema databases. |
|
none |
PostgreSQL schema or MySQL database for the schema version tables. |
|
|
Separates the history of several projects stored in one database. |
|
|
Seconds to wait for the migration lock; |
|
|
Elasticsearch URL ( |
|
|
Extra HTTP headers sent with every request. |
|
|
Request timeout in seconds; |
|
none |
Basic authentication. |
|
none |
Encoded API key, sent as |
|
none |
CA bundle used to verify the server certificate. |
|
|
Set |
|
none |
Client certificate (chain) for mutual TLS. |
|
none |
Private key, if not included in |
|
none |
Passphrase of an encrypted private key. |
|
none |
Write a debug log file with an audit trail. See Logging and audit trail. |
|
|
|
|
|
Size limit for |
|
|
Rotated files kept by |
The SCHEMA_PATTERN environment variable overrides the script filename pattern; see Migration scripts.
Showing the configuration¶
esmigrate config prints the effective profile. Passwords, API keys, key passphrases, Authorization headers and the
password in schema_db are masked.