title: Android Room: How to Migrate Column Renaming?
body: <h1>Issue</h1>
  
  <p>My app is crashing because I am not handling migration properly. <strong>I'm looking for a solution to migrate the name of 1 column in my table.</strong> </p>
  
  <p>In my project I a have a room table named '<em>content</em>' with a <strong>Double</strong> attribute '<em>archivedCount</em>'. In the latest version of the app the attribute <em>archivedCount</em> attribute is re-named to <em>dismissCount</em>, still as type <strong>Double.</strong></p>
  
  <p><strong>Original Content model</strong></p>
  
  <pre><code>@Entity(tableName = "content")
  data class Content(@PrimaryKey var id: String, var archiveCount: Double) : Parcelable {...}
  </code></pre>
  
  <p><strong>New Content model</strong></p>
  
  <pre><code>@Entity(tableName = "content")
  data class Content(@PrimaryKey var id: String, var dismissCount: Double) : Parcelable {...}
  </code></pre>
  
  <h1>Attempted Solution</h1>
  
  <p>After reading a Google Developer Advocate's explanation <a href="https://medium.com/androiddevelopers/understanding-migrations-with-room-f01e04b07929" rel="noreferrer">Understanding migrations with Room</a>, I attempted her solution outlined in the post's section <strong>Migrations with complex schema changes</strong> which entails making a copy of the original table, deleting the old table, then renaming the newly created table.</p>
  
  <p>With the following approach below there is a runtime error on this line: <code>database.execSQL("INSERT INTO content_new (id, dismissCount) SELECT id, archiveCount FROM users");</code> because I already cleared my app's cache so the old table no longer exists. </p>
  
  <p><strong>Can I update a single column without re-creating the entire table?</strong></p>
  
  <pre><code>static final Migration MIGRATION_1_2 = new Migration(1, 2) {
  @Override
  public void migrate(SupportSQLiteDatabase database) {
      // Create the new table
      database.execSQL(
              "CREATE TABLE content_new (id TEXT, dismissCount REAL, PRIMARY KEY(id))");
      // Copy the data
      database.execSQL("INSERT INTO content_new (id, dismissCount) SELECT id, archiveCount FROM users");
      // Remove the old table
      database.execSQL("DROP TABLE content");
      // Change the table name to the correct one
      database.execSQL("ALTER TABLE content_new RENAME TO content");
    }
  };
  </code></pre>