mirror of
https://github.com/TECHNOFAB11/dbmate.git
synced 2026-02-02 17:35:08 +01:00
postgres: Automatically create search_path schema when needed (#169)
In #167 we added support for specifying a postgres `search_path`, which is used to store the `schema_migrations` table. However, if the schema does not already exist it will cause an error. In this PR we automatically create the first schema in the `search_path` if it does not exist.
This commit is contained in:
parent
55a8065efe
commit
ac718a23dc
11 changed files with 146 additions and 67 deletions
|
|
@ -140,7 +140,7 @@ DATABASE_URL="postgres://username:password@/database_name?socket=/var/run/postgr
|
|||
```
|
||||
|
||||
A `search_path` parameter can be used to specify the [current schema](https://www.postgresql.org/docs/13/ddl-schemas.html#DDL-SCHEMAS-PATH) while applying migrations, as well as for dbmate's `schema_migrations` table.
|
||||
If multiple comma-separated schemas are passed, the first will be used for the `schema_migrations` table.
|
||||
If the schema does not exist, it will be created automatically. If multiple comma-separated schemas are passed, the first will be used for the `schema_migrations` table.
|
||||
|
||||
```sh
|
||||
DATABASE_URL="postgres://username:password@127.0.0.1:5432/database_name?search_path=myschema"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue