mercredi 4 novembre 2015

Sqlite column fails to create in creation time

I'm facing a strange problem. I'm creating a db in sqlite with the below query

String GROUP_TABLE = "groups";
String ROW_ID = "rowid";
String GROUP_ID = "GroupID";
String GROUP_NAME = "GroupName";
String GROUP_STATUS = "GroupStatus";
String IS_ADMIN = "IsAdmin";
String GROUP_TYPE = "GroupType";
String IS_PUBLIC = "IsPublic";
String LAST_UPDATE = "LastUpdate";

String groupQuery = "CREATE TABLE IF NOT EXISTS "+ GROUP_TABLE +" ("
        +ROW_ID+" INTEGER PRIMARY KEY, "
        +GROUP_ID+" TEXT, "
        +GROUP_NAME+" TEXT, "
        +GROUP_STATUS+" TEXT, "
        +GROUP_TYPE+" TEXT, "
        +IS_ADMIN+" TEXT, "
        +IS_PUBLIC+" TEXT, "
        +LAST_UPDATE+" TEXT);";

This is the schema given by sqlite adb command

H:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools>sqlite3
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open mydb.db
sqlite> .full schema
Usage: .fullschema
sqlite> .fullschema
CREATE TABLE android_metadata (locale TEXT);
CREATE TABLE groups (rowid INTEGER PRIMARY KEY, GroupID TEXT, GroupName     TEXT, GroupStatus TEXT, GroupType TEXT, IsAdmin TEXT, IsPubli
c TEXT, LastUpdate TEXT);
/* No STAT tables available */

and when I enter records for the first time there will be no problem. But when I try to enter records next time i get

E/SQLiteLog﹕ (1) table groups has no column named LastUpdate
11-04 14:35:01.850  11947-11974/? E/SQLiteDatabase﹕ Error inserting         GroupType=1 GroupID=553 LastUpdate=2015-08-08T14:17:14.000Z IsAdmin=1     GroupName=SAIFOOTWEARS GroupStatus=1
android.database.sqlite.SQLiteException: table groups has no column named     LastUpdate (code 1): , while compiling: INSERT INTO     groups(GroupType,GroupID,LastUpdate,IsAdmin,GroupName,GroupStatus) VALUES     (?,?,?,?,?,?)

And when I check the schema again the column is missing.

H:\adt-bundle-windows-x86_64-20140702\sdk\platform-tools>sqlite3
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .open mydb.db
sqlite> .fullschema
CREATE TABLE android_metadata (locale TEXT);
CREATE TABLE groups ( rowId INTEGER PRIMARY KEY,GroupID TEXT, GroupName     TEXT,GroupStatus TEXT,IsAdmin TEXT, GroupType TEXT, IsPublic
TEXT);
/* No STAT tables available */

Any leads on this would be of great help.

Aucun commentaire:

Enregistrer un commentaire