Ruby on rails 在rails中为Cassandra定义表复合主键
给定以下伪cql表结构:Ruby on rails 在rails中为Cassandra定义表复合主键,ruby-on-rails,cassandra,cequel,Ruby On Rails,Cassandra,Cequel,给定以下伪cql表结构: CREATE TABLE searches ( category text, timestamp timestamp, no_of_searches int, avg_searches double, PRIMARY KEY((category, timestamp), no_of_searches) ); 以及以下Rails Cequel型号: class Search include Cequel::Record # Tabl
CREATE TABLE searches (
category text,
timestamp timestamp,
no_of_searches int,
avg_searches double,
PRIMARY KEY((category, timestamp), no_of_searches)
);
以及以下Rails Cequel型号:
class Search
include Cequel::Record
# Table columns
key :category, :text
key :timestamp, :timestamp
key :no_of_searches, :int
column :avg_searches, :double
end
当我尝试使用以下方式同步模型时:
rake cequel:migrate
抛出以下rake错误:
rake aborted!
Cequel::InvalidSchemaMigration: Existing partition keys category,timestamp differ from specified partition keys timestamp
我试图让上面的rails模型使用分区键与上面的表同步,尽管它指出这两组键是不同的。我尝试过以相同的顺序定义键,但没有成功
我的目标是使用rails模型获得带有分区键的预定义数据库表。任何帮助都将不胜感激 key方法支持选项散列作为第三个参数。选项散列为定义的键添加了进一步的支持,例如
顺序
和分区
根据给定的表定义,这意味着您的表列将如下所示:
# Table columns
key :category, :text, { partition: true }
key :timestamp, :timestamp, { partition: true }
key :no_of_searches, :int
column :avg_searches, :double
不幸的是,Cequel自述文件中没有记录这一点,但是代码中记录了这一点,可以找到