Rails Migration 使列为 null =>真的 [英] Rails Migration to make a column null => true

查看:11
本文介绍了Rails Migration 使列为 null =>真的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最初创建了一个列为的表

I had originally created a table with column as

t.string   "email",  :default => "", :null => false

要求已更改,现在我需要允许电子邮件为空.如何编写迁移以使 :null => true

The requirement has changed and now I need to allow email to be null. How can I write a migration to make :null => true

推荐答案

试试:

change_column :table_name, :email, :string, null: true

这篇关于Rails Migration 使列为 null =>真的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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