-1

I was trying to run migration while renaming a column in room database. My code is following

    public static final Migration MIGRATION_11_12 = new Migration(11, 12) {
        @Override
        public void migrate(SupportSQLiteDatabase database) {
            database.execSQL("ALTER TABLE content RENAME COLUMN archiveCount TO dismissCount");
        }
    };

Besides android studio is detecting the following error

enter image description here

Although, it was compiling without any problem .

And I am getting the following error in the above code , while running migration test

android.database.sqlite.SQLiteException: near "COLUMN": syntax error (code 1)
mW3
  • 189
  • 3
  • 25
  • The same mentioned in https://stackoverflow.com/questions/52657760/android-room-how-to-migrate-column-renaming – Ajay Mehta Apr 19 '19 at 12:34
  • I have seen that , I exactly followed this , but the getting the error mentioned in my question . – mW3 Apr 19 '19 at 12:39
  • Possible duplicate of [Android Room: How to Migrate Column Renaming?](https://stackoverflow.com/questions/52657760/android-room-how-to-migrate-column-renaming) – karan Apr 19 '19 at 12:49
  • Does this answer your question? [How do I rename a column in a SQLite database table?](https://stackoverflow.com/questions/805363/how-do-i-rename-a-column-in-a-sqlite-database-table) – Xid Nov 10 '21 at 03:19

1 Answers1

-2
database.execSQL("ALTER TABLE content RENAME archiveCount TO dismissCount");

ALTER TABLE content_new RENAME TO content Remove COLUMN keyword from query.

Here is syntax

ALTER TABLE table_name 
RENAME column_name TO new_column_name;
Mehul Kabaria
  • 6,404
  • 4
  • 25
  • 50
  • 1
    Same problem , android studio is showing same warning and , while building getting same error . – mW3 Apr 19 '19 at 12:38