11
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/kmdb/migrations/02_kmdb_partitions.rb', line 11
def up
%w(events properties aliases).each do |t|
sql = %Q{
ALTER TABLE #{t} CHANGE id id BIGINT NOT NULL
ALTER TABLE #{t} DROP PRIMARY KEY
CREATE UNIQUE INDEX index_events_partition ON #{t} (t, id)
CREATE INDEX index_events_id ON #{t} (id)
ALTER TABLE #{t} CHANGE id id BIGINT NOT NULL AUTO_INCREMENT
ALTER TABLE #{t} PARTITION BY RANGE COLUMNS (t) (PARTITION pLast VALUES LESS THAN MAXVALUE)
}
sql.strip.split(/\n/).each { |stmt| execute stmt.strip }
end
end
|