Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-6756] iOS: Database migration from 1.7.x -> 1.8.x is not copying migrating the data

GitHub Issuen/a
TypeBug
PriorityCritical
StatusClosed
ResolutionFixed
Resolution Date2011-12-20T14:21:19.000+0000
Affected Version/sRelease 1.7.5, Release 1.8.0.1
Fix Version/sRelease 1.7.6, Release 1.8.0.1, Sprint 2011-51, Release 2.0.0, Release 1.8.1
ComponentsiOS
Labelsmodule_filesystem, qe-testadded
ReporterMauro Parra-Miranda
AssigneeVishal Duggal
Created2011-12-19T10:39:37.000+0000
Updated2012-02-03T13:26:17.000+0000

Description

.h4 PROBLEM DESCRIPTION DB Migration for 1.7.x->1.8RC3 only copies the name of the database. The data is not being migrated. .h4 STEPS TO REPRODUCE 1. Copy the attached code into a new project. 2. Configure tiapp.xml to use 1.7.5. 3. Press the 'Create the DB button' 4. Press the 'Select on the DB button', so you can see that there is data in the db. 5. Close simulator. 6. Modify tiapp.xml to use 1.8RC3. 7. Recompile 8. Open App, and press 'Select on the DB button'. It will complain that there is no data in the db. .h4 Code
var win = Ti.UI.createWindow({
	title:'db testing',
});

var db = Titanium.Database.open('mydb');

var l3 = Titanium.UI.createLabel({
	text:'unicode placeholder',
	width:300,
	height:40,
	top:160
});
win.add(l3);

var l = Titanium.UI.createLabel({
	text:'See Log for output',
	top:10,
	left:10,
	height:'auto',
	width:'auto'
});
win.add(l);

var b1 = Titanium.UI.createButton({
	title:'Create the DB',
	width:200,
	height:40,
	top:40
});
win.add(b1);

b1.addEventListener('click', function()
{	var l1 = Titanium.UI.createLabel({
		text:'2nd context test - see log.',
		color:'#fff',
		font:{fontSize:14},
		width:'auto',
		height:'auto'
	});
	
	win.add(l1);
var db = Titanium.Database.open('mydb');
db.execute('CREATE TABLE IF NOT EXISTS DATABASETEST  (ID INTEGER, NAME TEXT)');
db.execute('DELETE FROM DATABASETEST');

db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',1,'Name 1');
db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',2,'Name 2');
db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',3,'Name 3');
db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)',4,'Name 4');
db.execute('INSERT INTO DATABASETEST (ID, NAME ) VALUES(?,?)', 5, '\u2070 \u00B9 \u00B2 \u00B3 \u2074 \u2075 \u2076 \u2077 \u2078 \u2079');
var updateName = 'I was updated';
var updateId = 4;
db.execute('UPDATE DATABASETEST SET NAME = ? WHERE ID = ?', updateName, updateId);

db.execute('UPDATE DATABASETEST SET NAME = "I was updated too" WHERE ID = 2');

db.execute('DELETE FROM DATABASETEST WHERE ID = ?',1);

Titanium.API.info('JUST INSERTED, rowsAffected = ' + db.rowsAffected);
Titanium.API.info('JUST INSERTED, lastInsertRowId = ' + db.lastInsertRowId);
db.close();
});

var b2 = Titanium.UI.createButton({
	title:'Select on the db',
	width:200,
	height:40,
	top:100
});
win.add(b2);

b2.addEventListener('click', function()
{
var db = Titanium.Database.open('mydb');
var rows = db.execute('SELECT * FROM DATABASETEST');
Titanium.API.info('ROW COUNT = ' + rows.getRowCount());
Titanium.API.info('ROW COUNT = ' + rows.getRowCount());
Titanium.API.info('ROW COUNT = ' + rows.getRowCount());

while (rows.isValidRow())
{
	Titanium.API.info('ID: ' + rows.field(0) + ' NAME: ' + rows.fieldByName('name') + ' COLUMN NAME ' + rows.fieldName(0));
	if (rows.field(0)==5)
	{
		l3.text = rows.fieldByName('name');
	}

	rows.next();
}
rows.close();
db.close(); // close db when you're done to save resources
	var l2= Titanium.UI.createLabel({
		text:'Check the select - see log.',
		color:'#fff',
		font:{fontSize:14},
		width:'auto',
		height:'auto',
		top:400,
	});
	win.add(l2);
});
var l3 = Titanium.UI.createLabel({
	text:'unicode placeholder',
	width:300,
	height:40,
	top:160
});

win.open();

Comments

  1. Vishal Duggal 2011-12-19

    Pull Pending #1053 against master #1056 against 1_7_X #1057 against 1_8_X
  2. Michael Pettiford 2012-01-13

    Closing issue Tested with Ti Studio 1.0.8.201201101928 Ti Mob SDK 1.9.0.v20120111233134 OSX Lion iPhone 4S, iPad 2 Expected behavior of DB being transferred between compilations from one SDK version to another is shown

JSON Source