i want to partition my table. the table is:
create_table "multimedia", :force => true do |t|
t.integer "id"
t. binary "data"
t.integer "device_id"
t.datetime "created_at"
end
id
is the primary key
created_at is a simple index for the table and there isn't unique
i need to partition the table by the field created_at. In my table there's only record from the last 7 days so i want to partition it by the day. i write this cose:
partition by range (to_days(created_at))
( PARTITION p20120417 VALUES LESS THAN (to_days('2012-04-17 23:59:59 +0200')),
PARTITION p20120418 VALUES LESS THAN (to_days('2012-04-18 23:59:59 +0200')),
PARTITION p20120419 VALUES LESS THAN (to_days('2012-04-19 23:59:59 +0200')),
PARTITION p20120420 VALUES LESS THAN (to_days('2012-04-20 23:59:59 +0200')),
PARTITION p20120421 VALUES LESS THAN (to_days('2012-04-21 23:59:59 +0200')),
PARTITION p20120422 VALUES LESS THAN (to_days('2012-04-22 23:59:59 +0200')),
PARTITION p20120423 VALUES LESS THAN (to_days('2012-04-23 23:59:59 +0200')),
PARTITION p20120424 VALUES LESS THAN (to_days('2012-04-24 23:59:59 +0200'))
);
the code give me this error:
A PRIMARY KEY must included all columns in the table's partitioning function
i need that the table is partition only by created_at and it can't be unique.
How can i do?