Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Migrate from id to guid

See original GitHub issue

Current state

  • The id XML attribute is parsed from the schedule XML and used with the app.
    • Used to compose PendingIntent in AlarmServices.
    • Used to compose PendingIntent in AlarmReceiver.
    • Rendered in session details screen.
    • Used to persist and query data in sessions, alerts and highlights database tables.
  • id values are not guaranteed to be unique - id values used for different sessions cause errors. See
  • New session data is compared and modified in the ScheduleChanges class.
  • New session data is persisted by first deleting all old session data and then inserting all new session data in one transaction. See SessionsDatabaseRepository#insert.
  • The sessions table does mark any of its columns as primary key nor use an auto-increment key.

Target state

  • The guid XML attribute is parsed from the schedule XML and used with the app.
    • Used to persist and query data in sessions, alerts and highlights database tables.


  • Stop parsing sessionId as an Integer in AlarmServices to compose a PendingIntent.
  • Resolve sessionId being used as an Integer in AlarmReceiver#onReceive to compose a PendingIntent.
  • Migrate Highlight#sessionId from Int to String. See HighlightDBOpenHelper.


  • Parse guid XML attribute.
  • Use guid within the app.
  • Check if id XML attribute can be removed. -> Removed.
  • Revise SessionUrlComposer and related tests.
  • Update sample data in tests - use typical guid sample data.
  • Display guid value? -> No value for the user.
  • Clarify if data can be kept on application update. -> Data will be wiped on application update.
  • Clarify if Chaosflix export will be broken when moving from id to guid.


Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:10 (8 by maintainers)

github_iconTop GitHub Comments

NiciDieNasecommented, Dec 12, 2020

@NiciDieNase Can you tell if the JSON import in the Chaosflix app will be broken when I move from id to guid here?

No, should not be affected, chaoflix uses guid for importing.

cketticommented, Nov 4, 2020

I think a better approach would be to use an auto-incrementing INTEGER column to uniquely identify a session in the database. This will keep the app simple in situations where stable numeric identifiers are required or at least very helpful (e.g. in a RecyclerView.Adapter).

This way only the code that maps between network model and app model has to be aware of GUIDs. If the identifier in the network format changes in the future only the mapping code needs to be updated.

Using that approach also allows splitting this change into two parts:

  1. Change app to use its own unique session ID.
  2. Change mapping code to use guid attribute instead of id attribute for matching items.
Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I change an int ID column to Guid with EF migration?
I'm using EF code-first approach and want to change the Id field to guid ...
Read more >
Migrating from int-based primary keys to GUID? : r/csharp
Overall, it's pretty straightforward. Add a column for each table with the new ID, generate a GUID for each row, update all navigation ......
Read more >
Id to Uuid migration classes for Doctrine - GitHub
Easily migrate from an auto incremented integer id to a uuid in a project using DoctrineMigrationsBundle. Autodetect your foreign keys and update them....
Read more >
Migrations and Seed Data With Entity Framework Core
EF Core provides a method called Migrate to execute migration actions for us. ... Column<Guid>(nullable: false), ... Id = Guid.NewGuid(),.
Read more >
UUID Primary Key in Elixir Phoenix with PostgreSQL and Ecto
Changing the primary key type in the table is not straightforward. You need to start by running a similar migration that will create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found