From de9b4ab4dc4852d9fe00f854bf518330561a1113 Mon Sep 17 00:00:00 2001 From: Tobi Date: Tue, 16 Nov 2021 22:47:57 +0100 Subject: [PATCH] Add draft for Database page --- Database.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 Database.md diff --git a/Database.md b/Database.md new file mode 100644 index 0000000..ab14635 --- /dev/null +++ b/Database.md @@ -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