Fix for postgres driver blindly recreating the migrations table #89

merged 1 commit into from Apr 18, 2013


None yet

2 participants


Despite this ticket: #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.

@sgibbons sgibbons The postgres driver blindly creates the migrations table regardless o…
…f whether or not it's already been created - this change to the driver first checks the information schema for the existence of the table and does/doesn't create it accordingly
@kunklejr kunklejr merged commit 545b706 into db-migrate:master Apr 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment