@Override public void create(SQLiteDatabase db) { String sql; sql = "CREATE TABLE " + NAME + " (" + Fields._ID + " INTEGER PRIMARY KEY," + Fields.ACCOUNT + " TEXT," + Fields.ROOM + " TEXT," + Fields.NICKNAME + " TEXT," + Fields.PASSWORD + " TEXT," + Fields.NEED_JOIN + " INTEGER);"; DatabaseManager.execSQL(db, sql); sql = "CREATE UNIQUE INDEX " + NAME + "_list ON " + NAME + " (" + Fields.ACCOUNT + ", " + Fields.ROOM + ");"; DatabaseManager.execSQL(db, sql); }
@Override public void migrate(SQLiteDatabase db, int toVersion) { super.migrate(db, toVersion); String sql; switch (toVersion) { case 24: sql = "CREATE TABLE rooms (_id INTEGER PRIMARY KEY," + "account TEXT," + "room TEXT," + "nickname TEXT," + "password TEXT," + "timestamp INTEGER);"; DatabaseManager.execSQL(db, sql); sql = "CREATE UNIQUE INDEX rooms_list ON rooms (account, room);"; DatabaseManager.execSQL(db, sql); break; case 25: DatabaseManager.dropTable(db, "rooms"); sql = "CREATE TABLE rooms (_id INTEGER PRIMARY KEY," + "account TEXT," + "room TEXT," + "nickname TEXT," + "password TEXT," + "need_join INTEGER);"; DatabaseManager.execSQL(db, sql); sql = "CREATE UNIQUE INDEX rooms_list ON rooms (account, room);"; DatabaseManager.execSQL(db, sql); break; default: break; } }