migrate/database/postgres
Lukas Joergensen 480a5a634a postgres: Move lock out of ensureVersionTable, for consistency with other SQL operations (#173)
* Consistently lock in ensureVersionTable and do not call ensureVersionTable from Drop across all database implementations

* Add test for dropping postgres databases

* Fix failing database tests

* Fix CockroachDb test, lock table should be created before versionTable

* Add Initialize() to Driver interface, and add integration tests for Drop() between database implementations and migrate

* Remove Initialize, document breaking behaviour of Drop

* Revert introduction of Initialize method

* Removed Initialize in Stub as well

* Remove call to non-existent Initialize and make sure to close re-initialized database connections

* Revert changes to TestDrop in database/testing

* Split Test and TestMigrate into different test entrypoints

* Remove unused import in migrate_testing

* Remove erroneous code to fix tests

* Add stub source imports to database tests

* Add Stub source to migrate tests

* Use example migrations for tests

* Add file driver to database tests

* Align database directory layout

* Add file source driver to Cassandra

* Review changes

* Minor syntactic change for cleaner diff
2019-02-26 15:56:57 -08:00
..
examples/migrations initial version 3.0.0 preview 2017-02-07 22:01:29 -08:00
README.md Update README.md 2017-04-25 11:06:06 -07:00
postgres.go postgres: Move lock out of ensureVersionTable, for consistency with other SQL operations (#173) 2019-02-26 15:56:57 -08:00
postgres_test.go postgres: Move lock out of ensureVersionTable, for consistency with other SQL operations (#173) 2019-02-26 15:56:57 -08:00

README.md

postgres

postgres://user:password@host:port/dbname?query (postgresql:// works, too)

URL Query WithInstance Config Description
x-migrations-table MigrationsTable Name of the migrations table
dbname DatabaseName The name of the database to connect to
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.
user The user to sign in as
password The user's password
host The host to connect to. Values that start with / are for unix domain sockets. (default is localhost)
port The port to bind to. (default is 5432)
fallback_application_name An application_name to fall back to if one isn't provided.
connect_timeout Maximum wait for connection, in seconds. Zero or not specified means wait indefinitely.
sslcert Cert file location. The file must contain PEM encoded data.
sslkey Key file location. The file must contain PEM encoded data.
sslrootcert The location of the root certificate file. The file must contain PEM encoded data.
sslmode Whether or not to use SSL (disable|require|verify-ca|verify-full)

Upgrading from v1

  1. Write down the current migration version from schema_migrations
  2. DROP TABLE schema_migrations
  3. Wrap your existing migrations in transactions (BEGIN/COMMIT) if you use multiple statements within one migration.
  4. Download and install the latest migrate version.
  5. Force the current migration version with migrate force <current_version>.