0
votes

I am trying to rebuild my development database from bare metal and am getting a strange error that I've not seen before. I cant seem to track down the cause. Here are the commands I am running and the results:

rake db:drop

rake db:create

rake db:migrate:status
  Schema migrations table does not exist yet.

rake db:migrate
  ==  CreateUser: migrating =====================================================
  -- create_table(:user)
     -> 0.0264s
  ==  CreateUser: migrated (0.0267s) ============================================

  rake aborted!
  An error has occurred, this and all later migrations canceled:

  PG::NotNullViolation: ERROR:  null value in column "version" violates not-null constraint
  DETAIL:  Failing row contains (null).
  : INSERT INTO "schema_migrations" DEFAULT VALUES
  /home/xxx/.rvm/gems/ruby-2.0.0-p451/gems/activerecord-4.0.3/lib/active_record/connection_adapters/postgresql_adapter.rb:774:in `async_exec'

I am fairly certain I have not modified the user migration file since last time I successfully migrated it. Have any of you seen this error before and resolved it?

1
Do you have a migration that does not start with timestamps by any chance? It looks like Postgre SQL is trying to insert a null value for the column version of your schema table... -- also, do you know what is DEFAULT VALUES? - MrYoshiji
What does that migration do? - tadman
The version insert is the start of the file name (usualy timestamp_migration_name.rb). I bet your migration file name starts with _. - fotanus
I deleted the first migration and tried again without it, but get the same error. The files are named correctly, i.e., 20140306165659_create_user.rb. It does not appear to be an issue with the migration files themselves. - Mike
Figured this out finally. As usual, its a stupid programmer's error. I had been working on an extension to ActiveRecord for my project and that extension was the source of this error. Once removed, migrations are working again. Thanks for everyone's help! - Mike

1 Answers

0
votes

Try :text instead of :string in migration.