Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-6756

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

    Details

      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

      app.js

      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();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                vduggal Vishal Duggal (Inactive)
                Reporter:
                mpmiranda Mauro Parra-Miranda
              • Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Backbone Issue Sync

                  • Titanium SDK/CLI <> Titanium Mobile
                    Synced with:
                    TIMOB-11433
                    Sync status:
                    ERROR
                    Last received:
                    Last sent:

                    Git Integration