Skip to content

fix(db): implement manual migration for Android >=15 combatibility#565

Open
AlexKaridas wants to merge 1 commit into
vivizzz007:mainfrom
AlexKaridas:fix_crash_on_startup_android15_redmi
Open

fix(db): implement manual migration for Android >=15 combatibility#565
AlexKaridas wants to merge 1 commit into
vivizzz007:mainfrom
AlexKaridas:fix_crash_on_startup_android15_redmi

Conversation

@AlexKaridas

Copy link
Copy Markdown

Title: Refactor: Consolidate Database Migrations (v28-34) and Improve Schema Safety
Overview
This PR introduces a comprehensive cleanup and fortification of our Room database migration logic. The primary goal is to consolidate recent migrations, standardize how we handle default values, and introduce reusable helpers to make future schema changes safer and less verbose.

Key Changes

Consolidated Migrations (v28 to v34)

Added a single, unified MIGRATION_28_34 to replace the individual auto-migrations for these versions in the @database annotation.

This consolidated migration handles adding columns, creating tables, and repairing default values, providing a cleaner and more predictable upgrade path.

Updated AppModule to use InternalDatabase.newInstance to ensure the new migration logic is applied correctly.

New Safety Helpers (safeAddColumn & fixSchema)

The Problem: Legacy migrations relied heavily on repetitive try/catch blocks and manual column existence checks, increasing the risk of human error.

The Solution: Introduced safeAddColumn and fixSchema helper functions.

Impact: Older migration specs (e.g., v21->v22, v23->v24) were refactored to use these helpers. This drastically reduces boilerplate, improves readability, and prevents migration crashes caused by duplicate columns.

Standardized Boolean Defaults

Standardized the default values for boolean columns in entity data classes (SongEntity, AlbumEntity, PlaylistEntity).

Switched from using .toString() on booleans to explicit string literals ("true"/"false"), ensuring strict consistency with Room and SQLite expectations.

Updated the 34.json schema file to reflect the new identity hash and these standardized setup queries.

Reviewer Notes

AI Assistance: Please note that AI tools were used to assist in generating parts of this refactoring and migration logic. Extra scrutiny during review is highly appreciated to ensure the schema changes and consolidated steps perfectly align with our specific database requirements.

To review the core logic changes, I recommend starting with the new safeAddColumn helper and the consolidated MIGRATION_28_34 implementation.

Note: The delegate property visibility in MusicDatabase was changed from private to internal to facilitate this new instantiation logic.

@AlexKaridas

Copy link
Copy Markdown
Author

I tested this implementation and it seems that the #564 is resolved after these changes, hopefully nothing else was affected.

@lscherub

Copy link
Copy Markdown

What are we waiting for?

@SaltyRhino95857

Copy link
Copy Markdown

seriously when is this gonna get merged i need my music

@lscherub

lscherub commented May 1, 2026

Copy link
Copy Markdown

seriously when is this gonna get merged i need my music

I don't think the maintainers care about their users, I switched back to opentune.

@SaltyRhino95857

Copy link
Copy Markdown

i think ill just compile this branch and hope that my phone wont reject this because its not signed by the creator

@lscherub

lscherub commented May 1, 2026

Copy link
Copy Markdown

i think ill just compile this branch and hope that my phone wont reject this because its not signed by the creator

Let me know how it goes!

@AlexKaridas

Copy link
Copy Markdown
Author

I have been using this version since i built it , and it works fine btw

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants