检查Rails中是否存在表 - Check if a table exists in Rails

问题:

I have a rake task that won't work unless a table exists. 我有一个rake任务,除非存在一个表,否则它将无效。 I'm working with more than 20 engineers on a website so I want to make sure they have migrated the table before they can do a rake task which will populate that respective table. 我正在一个网站上与20多名工程师一起工作,所以我想确保他们已经迁移了表,然后才能执行一个rake任务,该任务将填充相应的表。

Does AR have a method such as Table.exists ? AR有一个像Table.exists这样的方法吗? How can I make sure they have migrated the table successfully? 如何确保他们已成功迁移表?


解决方案:

参考一: https://en.stackoom.com/question/ReO3
参考二: https://stackoom.com/question/ReO3
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章