Closed CoreyFedde closed 7 years ago
Is it possible that the column you modified already had some null entries in it? Because Rails wouldn't like that.
Yes, there are entries in that column will null entries.
I believe you'll need to get rid of those before that migration can be successful.
The root of the problem was the server was not running while a migration was pending. After clearing the table of null values and running db:migrate, the problem was fixed.
Thanks, Caleb
Just an ordinary day of running a migration that failed which now is causing 500 internal server errors. (POST http://localhost:4741/sign-in/ 500 (Internal Server Error))
I created a migration to change a column in my database to not accept null data. When I ran it I got the error message below. Now I'm getting 500 server errors when trying to log in. Currently troubleshooting, but open to suggestions:
$ bin/rails db:migrate == 20170725134013 ChangeTitleNullFalse: migrating ============================= -- change_column_null(:movies, :title, false) rails aborted! StandardError: An error has occurred, this and all later migrations canceled:
PG::NotNullViolation: ERROR: column "title" contains null values : ALTER TABLE "movies" ALTER "title" SET NOT NULL /Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/db/migrate/20170725134013_change_title_null_false.rb:3:in'
ActiveRecord::StatementInvalid: PG::NotNullViolation: ERROR: column "title" contains null values
: ALTER TABLE "movies" ALTER "title" SET NOT NULL
/Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/db/migrate/20170725134013_change_title_null_false.rb:3:in '
PG::NotNullViolation: ERROR: column "title" contains null values
/Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/db/migrate/20170725134013_change_title_null_false.rb:3:in '
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
change' /Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/bin/rails:9:in
require' /Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/bin/rails:9:in<top (required)>' /Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/bin/spring:15:in
<top (required)>' bin/rails:3:inload' bin/rails:3:in
change' /Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/bin/rails:9:in
require' /Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/bin/rails:9:in<top (required)>' /Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/bin/spring:15:in
<top (required)>' bin/rails:3:inload' bin/rails:3:in
change' /Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/bin/rails:9:in
require' /Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/bin/rails:9:in<top (required)>' /Users/coreyfedde/wdi/projects/movie-list-project/movie-list-backend/bin/spring:15:in
<top (required)>' bin/rails:3:inload' bin/rails:3:in