Ruby 写了一个打印数据库表结构的 Gem

Ian · February 20, 2023 · Last by peter.zhang replied at February 21, 2023 · 806 hits

之前查看表结构的方式一直都是使用的 annotate 这个 gem,但是将表结构作为注释嵌入在模型里感觉不是很好,而且字段多的时候看起来不太舒服。所以想着能不能在 console 里边打印表结构,然后就有了这个 gem: table_inspector

大概的用法是:

TableInspector.scan [model_class]

输出结果类似:

table_inspector_scan_table

更多用法写在 README 里边了: https://github.com/otorain/table_inspector

You need to Sign in before reply, if you don't have an account, please Sign up first.