ios - How to upgrade database version in sqlite and add new column in table in swift -
i've created sqlite tables app, want add new column in table database. alter table me in problem first want check database version. using pragma user_version check user version , update user_version returning user_version 0.
var database: fmdatabase? = nil class func getinstance() -> modelmanager{ if(sharedinstance.database == nil){ sharedinstance.database = fmdatabase(path: util.getpath("xxxx.sqlite")) } return sharedinstance } func userversion(){ sharedinstance.database!.open() var userver = int() let resultset = sharedinstance.database?.executequery("pragma user_version", withargumentsinarray: nil) userver = int(resultset!.intforcolumn("user_version")) print("user version : ",userver) sharedinstance.database!.close() } func updateuserversion(){ sharedinstance.database!.open() sharedinstance.database?.executeupdate("pragma user_version=1", withargumentsinarray: nil) sharedinstance.database!.close() }
follow these steps access database mozila-firefox:
1] download mozila browser 2] in tools select sqlite-manager option. 3]in browse project sqlite database file 4] , whatever changes want on table created.
hope work you.
Comments
Post a Comment