in mysql, you can set the following environment variables:
set @@auto_increment_offset = 4;
set @@auto_increment_increment =10;
create table people (id int auto_increment primary key, name char(100));
insert into people set name=‘Giuseppe’;
insert into people set name=‘Laura’;
select * from people;
| id | name |
| 4 | Giuseppe |
| 14 | Laura |
As you can see, thosee two variables determine the id that will be used
for the first insert, and the increment for all subsequent inserts.
ActiveRecord seems to ignore this. In fact, if you use Rails to append
new records to this table, the third row will get an id of 15 (instead
of 24, as I would like).
I have unsuccessfully gone through the AR lib in search of the mechanism
used by AR to determine ids for new records in a mysql connection.
Could anyone suggest a DRY way to either get AR to follow the scheme set
in mysql or to override AR’s behavior and impose custom
increment/offsets for id fields?
Incidentally, this request stems from the need to set up multiple-master