github.com/scraniel/migrate@v0.0.0-20230320185700-339088f36cee/database/postgres/README.md (about) 1 # postgres 2 3 `postgres://user:password@host:port/dbname?query` (`postgresql://` works, too) 4 5 | URL Query | WithInstance Config | Description | 6 |------------|---------------------|-------------| 7 | `x-migrations-table` | `MigrationsTable` | Name of the migrations table | 8 | `x-migrations-table-quoted` | `MigrationsTableQuoted` | By default, migrate quotes the migration table for SQL injection safety reasons. This option disable quoting and naively checks that you have quoted the migration table name. e.g. `"my_schema"."schema_migrations"` | 9 | `x-statement-timeout` | `StatementTimeout` | Abort any statement that takes more than the specified number of milliseconds | 10 | `x-multi-statement` | `MultiStatementEnabled` | Enable multi-statement execution (default: false) | 11 | `x-multi-statement-max-size` | `MultiStatementMaxSize` | Maximum size of single statement in bytes (default: 10MB) | 12 | `dbname` | `DatabaseName` | The name of the database to connect to | 13 | `search_path` | | This variable specifies the order in which schemas are searched when an object is referenced by a simple name with no schema specified. | 14 | `user` | | The user to sign in as | 15 | `password` | | The user's password | 16 | `host` | | The host to connect to. Values that start with / are for unix domain sockets. (default is localhost) | 17 | `port` | | The port to bind to. (default is 5432) | 18 | `fallback_application_name` | | An application_name to fall back to if one isn't provided. | 19 | `connect_timeout` | | Maximum wait for connection, in seconds. Zero or not specified means wait indefinitely. | 20 | `sslcert` | | Cert file location. The file must contain PEM encoded data. | 21 | `sslkey` | | Key file location. The file must contain PEM encoded data. | 22 | `sslrootcert` | | The location of the root certificate file. The file must contain PEM encoded data. | 23 | `sslmode` | | Whether or not to use SSL (disable\|require\|verify-ca\|verify-full) | 24 25 26 ## Upgrading from v1 27 28 1. Write down the current migration version from schema_migrations 29 1. `DROP TABLE schema_migrations` 30 2. Wrap your existing migrations in transactions ([BEGIN/COMMIT](https://www.postgresql.org/docs/current/static/transaction-iso.html)) if you use multiple statements within one migration. 31 3. Download and install the latest migrate version. 32 4. Force the current migration version with `migrate force <current_version>`. 33 34 ## Multi-statement mode 35 36 In PostgreSQL running multiple SQL statements in one `Exec` executes them inside a transaction. Sometimes this 37 behavior is not desirable because some statements can be only run outside of transaction (e.g. 38 `CREATE INDEX CONCURRENTLY`). If you want to use `CREATE INDEX CONCURRENTLY` without activating multi-statement mode 39 you have to put such statements in a separate migration files.