title: Having create fail when id already exists
body: <p>I'm using a rake task to populate my database with some initial data. I want to create a bunch of entries in a table, with the first few IDs, so they're always present, and always have those ids. I don't mind if in a dev environment, someone adds/deletes/modifies records, but I always want the first 5 ids to have values. Here's a simplified version of my lib/tasks/bootstrap.rb file:</p>
  
  <pre><code>namespace :bootstrap do
      desc "Create the default problem types"
      task :default_problem_types =&gt; :environment do
          ProblemType.create( :id =&gt; 1, :name =&gt; 'Wrong location', :description =&gt; 'blah' )
          ProblemType.create( :id =&gt; 2, :name =&gt;  'Wrong name', :description =&gt; 'blah' )
          ProblemType.create( :id =&gt; 3, :name =&gt;  'Wrong details', :description =&gt; 'blah' )
          ProblemType.create( :id =&gt; 4, :name =&gt;  'Duplicate', :description =&gt; 'blah' )
          ProblemType.create( :id =&gt; 5, :name =&gt;  'No longer exists', :description =&gt; 'blah' )
      end
  
      desc "Run all bootstrapping tasks"
      task :all =&gt; [:default_problem_types]
  end
  </code></pre>
  
  <p>This works fine on an empty database. It creates 5 new entries in the problem_types table:</p>
  
  <pre><code>1 - Wrong Location 
  2 - Wrong name 
  3 - Wrong details 
  4 - Duplicate 
  5 - No longer exists
  </code></pre>
  
  <p>The problem is that if I run it a second time, it creates 5 new records, with IDs 6, 7, 8, 9, 10. That's despite the fact that I provided ids to the create() call that already exist. I'm expecting those calls to fail, because if I try to do the following SQL:</p>
  
  <pre><code>insert into problem_types (id, name, description) values (1, 'foo', 'bar');
  </code></pre>
  
  <p>... it fails:</p>
  
  <p>ERROR 1062 (23000): Duplicate entry '1' for key 'PRIMARY'</p>
  
  <p>How do I get the create() method to fail if the ID already exists?</p>
  
  <p>Thanks.</p>