1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2024-11-22 01:55:22 +01:00

Add draft for Database page

Tobi 2021-11-16 22:47:57 +01:00
parent 416dff4fa7
commit de9b4ab4dc

16
Database.md Normal file

@ -0,0 +1,16 @@
**_This page is in an early state and not yet completed or reviewed!_**
This pages gives some information on the internal app database. In short, you learn about the [database structure](#database-structure) and [how to modify it](#modifying-the-database-structure) as well as how to [access the stored data](#access-data).
## Database structure
NewPipe is a streaming frontend. For this reason, storing information on `streams` is the database's core functionality.
Basically, stream information is used for feeds, playlists and watch history.
![NewPipe's database structure](https://user-images.githubusercontent.com/17365767/141841352-eefcd324-abfe-480b-9626-17db21f6c9de.png)
### Modifying the database structure
When modifying the database structure, the [database version needs to be increased](https://github.com/TeamNewPipe/NewPipe/blob/dev/app/src/main/java/org/schabi/newpipe/database/AppDatabase.java#L41).
You also need to create a migration to update the structure on installations which run an old database version. This is done in the [`Migrations`](https://github.com/TeamNewPipe/NewPipe/blob/dev/app/src/main/java/org/schabi/newpipe/database/Migrations.java) class. After creating the migration, it needs to be [registered with the database](https://github.com/TeamNewPipe/NewPipe/blob/dev/app/src/main/java/org/schabi/newpipe/NewPipeDatabase.java#L26) to be executed if necessary.
## Access data
Add some info on the DAO pattern here; AppDatabase and NewPipeDatabase