【问题标题】:Sequel Migration: uninitialized constant Jsonb (NameError)Sequel Migration:未初始化的常量 Jsonb (NameError)
【发布时间】:2016-03-27 04:28:15
【问题描述】:

我将SequelPadrino 一起使用,以下迁移引发了uninitialized constant Jsonb (NameError) 错误:

Sequel.migration do
  up do
    alter_table :same_table do
      add_column :not_working, Jsonb
    end
  end
end

sales 表的 create_table 迁移使用 Jsonb 没有问题:

Sequel.migration do
  up do
    create_table :same_table do
      Jsonb :worked
    end
  end
end

【问题讨论】:

    标签: ruby postgresql sequel padrino


    【解决方案1】:

    Sequel source code 一样,列类型不应大写。一般来说,DSL 是关于定义类方法,而不是常量。

    Sequel.migration do
      up do
        alter_table :same_table do
        #                          ⇓⇓ NOTE SYMBOL     
          add_column :not_working, :jsonb
        end
      end
    end
    
    Sequel.migration do
      up do
        create_table :same_table do
        # ⇓ NOTE DOWNCASE
          jsonb :worked
        end
      end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-19
      • 2015-10-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-04
      • 2016-06-12
      • 2015-03-01
      相关资源
      最近更新 更多