Home>
Production environment

AWS
EC2
MariaDB
Nginx
Unicorn
Capistrano
Rails6

I'm checking the operation in the production environment.

ActiveRecord :: NotNullViolation (Mysql2 :: Error: Field'latitude' doesn't have a default value


In the production environment, the error amount was spit out like this.
When I looked it up, it was written that due to the nature of MySql, it could not be saved unless it had a value.

So I thought about putting the default value in the migrate file and dealing with it
I specified the latitude and longitude of Tokyo Tower by default

class CreatePhotos</pre>
<pre><code data-language = "console">ActiveRecord :: NotNullViolation (Mysql2 :: Error: Field'latitude' doesn't have a default value):


I can't get out of this error.
Do you know who you are? ??

Automatically deploy
We have already updated the database in the production environment

  • Answer # 1

    Maybe I added default after migrating create_table: photos once.
    Then it will not be added.
    Recreate the database from scratch
    Do you make a migration to add default
    please