title: SQLlite: strange "Abort due to constraint violation"
body: <p>I'm trying to rename a column of a table. I have a lot of tables with the word "<code>couleur</code>" and I renamed "manually" to "<code>bulle</code>".</p>
  
  <p>I've successfully renamed <code>main_groupecouleurs</code> to <code>main_groupebulles</code>. Now i'm working on <code>main_groupe</code>. I'm trying to rename <code>groupe_couleurs_id</code> to <code>groupe_bulles_id</code> </p>
  
  <p>The SQL is quite self-explaining:</p>
  
  <pre><code>BEGIN TRANSACTION;
  DROP INDEX main_groupe_fc5cee5b;
  CREATE TABLE main_groupe7e12
  (
      id INTEGER PRIMARY KEY NOT NULL,
      description TEXT NOT NULL,
      exemple TEXT,
      groupe_bulles_id INTEGER DEFAULT NULL,
      reference TEXT,
      FOREIGN KEY (groupe_bulles_id) REFERENCES main_groupebulles(id)
          DEFERRABLE INITIALLY DEFERRED
  );
  CREATE UNIQUE INDEX main_groupe_fc5cee5b ON main_groupe7e12 (groupe_bulles_id);
  INSERT INTO main_groupe7e12(id, description, exemple, groupe_bulles_id, reference)
                       SELECT id, description, exemple, groupe_couleurs_id, reference
                       FROM main_groupe;
  DROP TABLE main_groupe;
  ALTER TABLE main_groupe7e12 RENAME TO main_groupe;
  COMMIT;
  </code></pre>
  
  <p>When I run it, I get:</p>
  
  <pre><code>[SQLITE_CONSTRAINT]  Abort due to constraint violation
      (UNIQUE constraint failed: main_groupe7e12.groupe_bulles_id)
  </code></pre>
  
  <p>This means (I think I'm wrong here but I dont know what I'm missing) that it tries to insert some <code>groupe_couleurs_id</code> that are <strong>not</strong> in the referring table (= <code>main_groupebulles</code>). Thus I tried to see in the original table the problem:</p>
  
  <pre><code>SELECT * FROM main_groupe WHERE groupe_couleurs_id NOT IN (
      SELECT id FROM main_groupebulles
  );
  </code></pre>
  
  <p>I got <em>no rows</em>! What am I missing?</p>