Showing posts with label migration. Show all posts
Showing posts with label migration. Show all posts

Friday, June 29, 2018

Inter-App Data Migration (migrating data to new app version)

Leave a Comment

I currently have a Swift iOS app on Apple's App Store. I have many users and I would like to make a new version and help current users migrate to the new version. FYI: the new version is an Ionic app.

Data-wise, my app is using Core Data without any iCloud or sync support. It contains JSON data and also multiple images. So I'd need to bundle the current data and find a way of bringing it to the new ionic app version.

Basically my question is: Is there a way of writing in the app's documents directory and let the new version grab that file to import its data? Is there a way of letting both apps transmit data other than AirDrop or Custom URLs?

I don't want to upload the data remotely, I'd like to do this all locally on the device and also seamlessly so the user don't have to manually do anything.

Suggestions are welcome, thanks!

2 Answers

Answers 1

I would have just left a comment but I am unable to do so.

I was able to see that after loading a native iOS application then a Ionic project with the same bundle structure that the data within Library/Application Support/DisplayName.sqlite was still there and the data within the database still intact. (Note: this is deploying using Xcode not through the App Store)

You can see this using Xcode -> Window -> Devices and Simulators -> Devices tab -> Click on your app -> settings cog -> Download container -> after saving Show package contents

I was unable to use the Ionic SQLite native plugin to open the database for some reason. That is as far as I could get. I think it might have something to do with the space of the Application Support folder.

Answers 2

You can do the transition without using AirDrop or Custom Url. The idea is based on how ionic works. Much of the ionic functionality depends upon the plugins developed by community like working with hardware features.

Dealing with device specific features are done in native codes then JS wrapper classes are created for making a bridge between your code and native code.

I would suggest you to write native code which will access the data and files from CoreData and then use the cordova plugin tech to setup communication between the native code and the ionic code. here is a good post on Creating Custom Plugin for ionic and a sample github project

Read More

Thursday, March 24, 2016

ALTER TABLE lhm migration deletes existing values

Leave a Comment
require 'lhm'  class RenameField1ToField2ForTable < ActiveRecord::Migration   def up     Lhm.change_table :table do |m|       m.ddl("ALTER TABLE %s CHANGE COLUMN field1 field2 FLOAT DEFAULT NULL AFTER field3" m.name)     end   end    def down     Lhm.change_table :table do |m|       m.ddl("ALTER TABLE %s CHANGE COLUMN field2 field1 FLOAT DEFAULT NULL AFTER field3" m.name)     end   end end 

What happend:

  1. Rails-4.0: rake db:migrate
  2. Field was renamed successfully.
  3. All existing field values are erased, why? Any ideas?

Edit:

  • old datatype was float(11)
  • MYSQL 5.6

3 Answers

Answers 1

I would highly suggest you utilize the methods made available to you from LHM that mimic the ones from Rails (if you plan to use LHM):

Lhm.change_table(:users) do |m|   m.change_column(:old_column, :float)   m.rename_column(:old_column, :new_column) end 

If you look at the method definitions, you will see LHM is doing a MODIFY where you are doing a CHANGE for change_column, and a CHANGE for rename_column.

Official Docs:

change_column: https://docs.omniref.com/ruby/gems/lhm/2.2.0/symbols/Lhm::Migrator/change_column?d=415590290&n=0#

rename_column: https://docs.omniref.com/github/soundcloud/lhm/2.2.0/symbols/Lhm::Migrator/rename_column?d=409846811&n=4#

Answers 2

Can you do a straight rails migration like so:

def change   rename_column :table_name, :old_column, :new_column end 

I've never used lhm so this might not be possible?

Also you might not need the "FLOAT DEFAULT NULL" in your current SQL statement if it's already specified in the DB.

Hope that helps.

Answers 3

rename 1st_name to temporary_name, and then rename 2nd_name to 1st_name, and then rename from temporary_name to 2nd_name

Read More