Skip to content
Extraits de code Groupes Projets
Vérifiée Valider 2e48abc8 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

RUST: Update the databse SQL file

parent 8f421123
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
DROP TABLE repo;
DROP TABLE kara_repo;
DROP TABLE repo_kara;
DROP TABLE kara;
DROP TABLE kara_makers;
DROP TABLE kara_tag;
DROP TABLE tag;
DROP TABLE kara_tags;
DROP TABLE history;
DROP TABLE ISO_639_1;
\ No newline at end of file
-- A list of repos karas where downloaded from. All repos should have different
-- names! Their IDs are local to the client.
CREATE TABLE repo
( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT
, name TEXT NOT NULL UNIQUE
);
-- Link a kara in the local referencial to its reference in the distant repo.
-- Local IDs are all uniques and every client should be expected to have
-- different ones.
CREATE TABLE repo_kara
( repo_id INTEGER NOT NULL REFERENCES repo(id)
, repo_kara_id INTEGER NOT NULL
......@@ -10,6 +15,7 @@ CREATE TABLE repo_kara
, PRIMARY KEY (repo_id, repo_kara_id, local_kara_id)
);
-- A kara entry in the databse.
CREATE TABLE kara
( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT
, is_dl BOOLEAN NOT NULL DEFAULT false
......@@ -17,21 +23,25 @@ CREATE TABLE kara
, song_type TEXT NOT NULL
, song_origin TEXT NOT NULL
, source_name TEXT NOT NULL
, language TEXT NOT NULL
, language TEXT NOT NULL REFERENCES ISO_639_1(code)
, kara_hash TEXT NOT NULL -- TEXT ABOVE + HASH OF FILE IN FS
);
-- We can have multiple kara makers for one kara.
CREATE TABLE kara_makers
( id INTEGER NOT NULL REFERENCES kara ON DELETE CASCADE
, name TEXT NOT NULL
, PRIMARY KEY (id, name)
);
-- Tags are informations used to be able to make queries in a easier way.
CREATE TABLE tag
( id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT
, name TEXT NOT NULL UNIQUE
);
-- The content of a tag for kara. Multiple tags for a single kara with the same
-- tag id means that there a list of values.
CREATE TABLE kara_tags
( kara_id INTEGER NOT NULL REFERENCES kara(id) ON DELETE CASCADE
, tag_id INTEGER NOT NULL REFERENCES tag(id) ON DELETE CASCADE
......@@ -39,7 +49,16 @@ CREATE TABLE kara_tags
, PRIMARY KEY (kara_id, tag_id, value)
);
-- Store the history of played karas from the queue. For now we allow a kara to
-- appear multiple times in the history.
CREATE TABLE history
( id INTEGER NOT NULL REFERENCES kara(id) ON DELETE CASCADE
, epoch INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT
);
-- The list of ISO 639-1 languages with their associated codes.
-- Should add an entry in the api to query available languages.
CREATE TABLE ISO_639_1
( code TEXT NOT NULL PRIMARY KEY
, name_en TEXT NOT NULL UNIQUE
);
\ No newline at end of file
// @generated automatically by Diesel CLI.
diesel::table! {
ISO_639_1 (code) {
code -> Text,
name_en -> Text,
}
}
diesel::table! {
history (epoch) {
id -> Integer,
......@@ -58,6 +65,7 @@ diesel::table! {
}
diesel::joinable!(history -> kara (id));
diesel::joinable!(kara -> ISO_639_1 (language));
diesel::joinable!(kara_makers -> kara (id));
diesel::joinable!(kara_tags -> kara (kara_id));
diesel::joinable!(kara_tags -> tag (tag_id));
......@@ -65,6 +73,7 @@ diesel::joinable!(repo_kara -> kara (local_kara_id));
diesel::joinable!(repo_kara -> repo (repo_id));
diesel::allow_tables_to_appear_in_same_query!(
ISO_639_1,
history,
kara,
kara_makers,
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter