Rails:db/schema.rb中的差异-null:created_at/updated_at列为false [英] Rails: differences in db/schema.rb - null: false at created_at/updated_at columns

查看:102
本文介绍了Rails:db/schema.rb中的差异-null:created_at/updated_at列为false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道为什么每次在生产环境中运行rake db:migrate时都会更改schema.rb文件吗?

Does anybody know why whenever I run rake db:migrate in my production environment, the schema.rb file is changed?

差异仅在所有模型表的created_at和update_at列上:

The differences are only on the created_at, update_at columns of all model tables:

-    t.datetime "created_at"
-    t.datetime "updated_at"
+    t.datetime "created_at",            null: false
+    t.datetime "updated_at",            null: false

我知道这就是在生产数据库中找到的内容,但是为什么要在这里将它们创建为null: false而不是在开发数据库中呢?

I know that this is what it finds in the production db, but why were they created as null: false there and not in the development db too?

推荐答案

我在开发机上也遇到了同样的事情.在生产环境中运行db:drop不是一个明智的主意,但是什么可以解决问题":

I had the same thing on my dev machine. Running db:drop in production is not a wise idea, but what will fix the 'problem':

rake db:drop db:create db:migrate

自从我第一次使用rails创建数据库以来,我的mysql版本已更改.迁移仍按照旧的mysql版本进行.

My mysql version had changed since I first created the database with rails. The migrations still ran according to the old mysql version.

这就是您的生产环境中可能发生的情况.

This is what probabaly happens at your production environment.

这篇关于Rails:db/schema.rb中的差异-null:created_at/updated_at列为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆