nearinfinity/node-db-migrate — pull request #89 by sgibbons (2013-04-13 18:15:26+00:00)
Title: Fix for postgres driver blindly recreating the migrations table

Despite this ticket: https://github.com/nearinfinity/node-db-migrate/issues/20 being marked as closed, I'm still experiencing this problem with the latest version.

As it exists now, the createMigrationsTable function in the pg driver has ifNotExists: false, which I assume is because pg doesn't support IF NOT EXISTS create statements. This results in the migrations table getting recreated each time the migrations are run, which results in a crash after the first run.

This change fixes the issue by querying the information_schema.tables table to check for the existence of a migrations table. If it exists, the creation of the table is skipped.