Rails:db/schema.rb中的差异

编程入门 行业动态 更新时间:2024-10-13 00:37:43
本文介绍了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中的差异

本文发布于:2023-10-18 04:27:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1503106.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:差异   db   Rails   rb   schema

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!