Я хочу, чтобы получить авто приращения колонки идентификатора для create_table рельсов команды для запуска на 500.Как установить начальное значение id на create_table?
я нашел примеры того, как установить начальное значение AUTO_INCREMENT идентификатора SQL:
CREATE TABLE student (id int(2) NOT NULL auto_increment, name varchar(50) NOT NULL default '', class varchar(10) NOT NULL default '', mark int(3) NOT NULL default '0', sex varchar(6) NOT NULL default 'male', UNIQUE KEY id (id)) auto_increment=100000 TYPE=MyISAM;
Так Я посмотрел на API Rails и видел эти параметры на create_table метода:
The options hash can include the following keys:
:id
Whether to automatically add a primary key column. Defaults to true. Join tables for has_and_belongs_to_many should set :id => false.
:primary_key
The name of the primary key, if one is to be added automatically. Defaults to id.
:options
Any extra options you want appended to the table definition.
:temporary
Make a temporary table.
:force
Set to true to drop the table before creating it. Defaults to false.
Не то, что мне нужно ... Я попытался это без успеха:
:options => {:auto_increment => 500}
Кто знает, как получить авто приращения колонки ID для этого заявления, чтобы начать на 500:
create_table :contents do |t|
t.string :type, :null => false
t.string :name, :null => false
end
Это сделал это! Благодаря! – Matthew
Хорошо - я не смог проверить его, когда отправил его! :-) –