title: OnUpgrade SQFLITE: Unhandled Exception: DatabaseException(table UsernameTable has no column named rememberMe (Sqlite code 1):
body: <blockquote>
    <p>Unhandled Exception: DatabaseException(table UsernameTable has no
    column named rememberMe (Sqlite code 1): , while compiling: INSERT OR
    REPLACE  INTO UsernameTable (username, rememberMe) VALUES (?, ?), (OS
    error - 2:No such file or directory)) sql 'INSERT OR REPLACE  INTO
    UsernameTable (username, rememberMe) VALUES (?, ?)' args [term@melfs,
    1]}</p>
  </blockquote>
  
  <p>I upgraded my DB. I added new column to <code>UsernameTable</code> Table. But It's not working. I have already so many records in this db. I can't <code>drop</code> So How I do add new column to exisiting db. I used <code>Sqflite</code></p>
  
  <pre><code> initDb() async {
      io.Directory documentsDirectory = await getApplicationDocumentsDirectory();
      String path = join(documentsDirectory.path, "HelperDatabase.db");
      var theDb = await openDatabase(path, version: 4, onCreate: _onCreate, onUpgrade: _onUpgrade);
      return theDb;
    }
  </code></pre>
  
  <p><strong>OnUpgrade method.</strong></p>
  
  <pre><code> void _onUpgrade(Database db, int oldVersion, int newVersion)async{
    if(oldVersion != 5){
        await db.execute("ALTER TABLE UsernameTable ADD COLUMN rememberMe INTEGER DEFAULT 0");
      }
    }
  </code></pre>
  
  <p><strong>onCreate method</strong></p>
  
  <pre><code>  void _onCreate(Database db, int version) async {
   await db.execute("""CREATE TABLE UsernameTable(username STRING)""");
  }
  </code></pre>