title: Can't assign id, "Column 'id' cannot be null"
body: <p>I inherited a database using Rails that doesn't set <code>id</code> incrementally, and also has two primary keys:</p>
  
  <pre><code>CREATE TABLE `t_user_history` (
  `id` int(11) NOT NULL,
  `history_no` int(11) NOT NULL,
  `user_login_id` varchar(10) COLLATE utf8_unicode_ci NOT NULL,
  `user_name` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `user_pass` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `created_at` datetime DEFAULT NULL,
  `updated_at` datetime DEFAULT NULL,
  `deleted_at` datetime DEFAULT NULL,
  `app_version` varchar(31) COLLATE utf8_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`history_no`,`id`)) 
  </code></pre>
  
  <p>However, when I try to insert into this table using ruby as such:</p>
  
  <pre><code>tuser = TUserHistory.find_by_id(user.id)
  TUserHistory.transaction do
  ntuser = TUserHistory.new
  ntuser.id = tuser.id
  ntuser.history_no = 0
  ntuser.user_login_id = tuser.user_login_id
  ntuser.user_name = tuser.user_name
  ntuser.user_pass = tuser.user_pass
  ntuser.app_version = params[:app]
  ntuser.save
  </code></pre>
  
  <p>I get the error: </p>
  
  <pre><code>getName {"error_code":"Mysql2::Error: Column 'id' cannot be null: INSERT INTO `t_user_history` 
  (`app_version`, `created_at`, `deleted_at`, `history_no`, `id`, `updated_at`, `user_login_id`, `user_name`, `user_pass`)
  VALUES ('v1.2.9', '2012-08-30 09:26:57', NULL, 0, NULL, '2012-08-30 09:26:57', 'userlogin', 'username', 'userpass')"}
  </code></pre>
  
  <p>Even if I set <code>ntuser.id = 9127</code> or some other value, it still says that <code>'id' cannot be null</code>.
  I looked at other answers that say it is indeed possible to modify this value, but it seems as though whatever value I attempt to set for <code>ntuser.id</code> gets ignored.</p>
  
  <p>Trashing the table and starting again in a sane manner is not allowed, as this table is already being used by our services.  I thought I'd create a new column for <code>user_id</code>, before I found out it didn't auto-increment, but even before getting to that step nothing, not even <code>ntuser.id = 0</code> or deleting the line that defines <code>ntuser.id</code>, works.</p>
  
  <p>What is going on here?  Why isn't it recognizing the data is has been passed?  What is the best (no, fastest) way to fix this?</p>
  
  <p>Edit: Rails version 3.1.0</p>
  
  <p>TUserHistory class:</p>
  
  <pre><code>class TUserHistory &lt; ActiveRecord::Base
  set_table_name "t_user_history"
  default_scope select("id, user_login_id,user_name,user_pass,app_version")
  acts_as_paranoid
  end
  </code></pre>