Automatically uninstalling the older app before installing the new one - android-studio

I published my app on play store and I have made an update that may cause the older one to crash due to some database structure changes that I have made and I have had a hell of hustle trying to automate DB migration upon installation. So I want the to completely auto-uninstall the old one from users phone before new one is installed during update as an easy solution. Is there a way I can include such configurations?

No, there is no way to force uninstallation before installation. But it sounds like you could just delete your DB on upgrade using SQLiteOpenHelper

If you use GreenDAO
you can use the schema version
Schema schema = new Schema(, "greendao");
when increasing the schema version GreenDAO will empty your DB and update the schema, and then you can repopulate it from the server (if applicable)

Related

Update LCI inputs from old to newer ecoinvent version

I have a big database of activities which in the LCI have activities from an old ecoinvent version.
Is there a fast and easy way to update all the LCIs in the database so that they use a newer version of ecoinvent?
I suppose there might be problems of activities not existing anymore/changed names, if that can be a case, how do you manage that?
I'm new to Brightway so I have no idea about how to do this ;).
Thanks a lot!
Daina
There isn't yet, but we are working on it. What we normally recommend is to have a reproducible workflow, using whatever data source you prefer. It is very helpful to be able to reproduce your projects if something happens to your computer, and in this case you could re-create your own data and link it to a newer version of whatever database. But you are right, things change from version to version, and this normally requires some metadata on how to handle these changes - hence the library under development.

How to manage number of migrations with Typeorm?

Apologies in advance as I am unable to find a good solution regarding this.
Background: We are using Typeorm in express app and have too many migrations because its a little old project.
Question: Is there a good way to manage migrations? Ideally I would want to delete all migrations(generated till now) and have only single file for schema creation(updated automatically after every migration run) and another file for seeding master data. Using these two files any new developer can setup the database locally in no time.
I worked in Ruby on rails and there used to be a clean approach like ruby maintains the database schema all the time in schema.rb and database could be generated using that.
I researched a lot but couldn't find a maintainable solution. May be the experts here could help me.
Thanks in advance
All your schemas describe your data model at current time, you can just delete all migrations from code and database, it will be as if you had no migrations at all. The problem will be only with old versions of your database which needs to be migrated.

Node global npm package, keeping up to date

I have published a global node package via npm to generate boilerplate templates for projects at my company.
I would like to compare the current version with the latest published in order to exit the process if it’s not the latest.
What node libraries would you recommend to check for the latest version.
Is there a way to auto update the global package if a new version is detected.
Remember this is an internal tool for my company so It’s critical they are creating projects with the latest templates and I’d like them to be able to update as automatically or easily as possible
Personal Suggestion
Instead of forcing the user to upgrade, another option is to publish your templates (as zip) on remote static server (e.g. S3). In such case, you can often update the zip to the latest template without upgrading the template generator.
generate-template angularjs-template:latest
generate-template angularjs-template:4.3
Answering Your Questions
What node libraries would you recommend to check for the latest version.
I am not sure if there is a library for this. However, you can build one very easily.
Create a JSON file which contains the package information (e.g. latest stable version, deprecation message, etc.).
Upload the JSON file to a remote static server.
Whenever the user runs your program, download the JSON file and check against the current package.json.
Show a deprecation warning if the user should upgrade.
process.exit() the application if the user must upgrade.
Is there a way to auto update the global package if a new version is detected.
I think it is better to leave the control to the user, because there could be some reasons why he doesn't prefer upgrade. For example, if the user has a bunch of projects started 10 months ago, he might want to use the same template for newer projects.
But if you really want to automate it, you might use the following code (not tested).
const { execSync } = require('child_process');
const pkg = require('./package.json')
execSync(`npm update -g ${pkg.name}`)
process.exit()

MagicalRecord v2.2 and simple lightweight migration for released app

I have an app in appstore and in which I had setup my magicalrecord using setupCoreDataStack method. I have since then versioned the data model and added an attribute to an existing entity. Now when I use setupCoreDataStackWithAutoMigratingSqliteStoreNamed to perform lightweight migration over the released app, the debug app opens with no data.
The new version of data model is currently selected with the green tickmark in xcode and is based on the old data model. The default value for the new attribute is set. If I install released version again without deleting the debug app from the device then I see the old data, means the old data is never wiped off (which is good), it's just not shown after setting up new version of the model and performing magicalrecord lightweight migration. What am I missing here?
There is no error in debugger while loading new debug version over existing released version. The filemerge diff performed on the contents of the data model versions only show the addition of the new attribute.
Any insight into this problem or pointers will help!
Huh, read somewhere that you can't auto-migrate if the datastore was not setup as an auto-migrate store in the first place. Someone suggested doing it over multiple releases. So assuming that was true, I tried
[MagicalRecord setupAutoMigratingCoreDataStack];
right before
[MagicalRecord setupCoreDataStackWithAutoMigratingSqliteStoreNamed:#"XYZ"];
and it worked.
Anyone else with same problem, no need to delete data store and create new with setupAutoMigratingCoreDataStack or try manual migration. Just setup as auto-migrate store and do auto-migration one after another in the same build. Hope it works for your too!

CoreData without changes in underlying models

Good day,
I have an app with CoreData that is in the Apps Store. I have now coded some
cosmetic changes in the interface without changing anything in the CoreData model.
I did not add/delete/or change any entity or property. Now, I am ready to upload my
version 2 of the app. I am unsure whether I have to do anything so that the old data
of the users in the first version will not be deleted but will be saved in the
new app (with exactly the same CoreData model). Please be tolerant with this noob.
Great thanks,
Romeo
When someone installs a new version of an app they already have, all the app's data stays where it is-- it doesn't get deleted.
Whether this data is compatible with the new version is a different question. If you haven't made any changes to the data model, then it should be fine. But you should make sure. Testing the upgrade process is one of the most important parts of testing a new version of an app. Install the current version, generate some data, and then install your new version and make sure everything looks OK. As you describe it, there shouldn't be any problems, but you should never just trust that this is the case.
In Marcus Zarra's Core Data Migration Course on iDeveloper TV, he suggests manually locking your xcdatamodel file so that you can't accidentally make updates to it and force a migration when you didn't plan it. But I agree with Tom, test it first.
iDeveloper.TV Core Data Migration

Resources