From: Jakub Czajka Date: Sat, 6 Jan 2024 13:41:30 +0000 (+0100) Subject: Categorise exercises by the muscles they target. X-Git-Url: https://git.ekhem.eu.org/?a=commitdiff_plain;h=794d2a6b6348c7ce7314e96cf58b6cf5026d954d;p=gym.git Categorise exercises by the muscles they target. --- diff --git a/COPYING b/COPYING index 9230d31..657d13b 100644 --- a/COPYING +++ b/COPYING @@ -631,7 +631,7 @@ to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. - Copyright (C) 2023 Jakub Czajka + Copyright (C) 2023-2024 Jakub Czajka This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -651,7 +651,7 @@ Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: - gym Copyright (C) 2023 Jakub Czajka + gym Copyright (C) 2023-2024 Jakub Czajka This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. diff --git a/create.sql b/create.sql index 7a7828c..67eefd7 100644 --- a/create.sql +++ b/create.sql @@ -1,11 +1,22 @@ -/* Copyright (c) 2023 Jakub Czajka +/* Copyright (c) 2023-2024 Jakub Czajka License: GPL-3.0 or later. */ +CREATE TABLE IF NOT EXISTS categories ( + id SERIAL PRIMARY KEY, + name VARCHAR(128) NOT NULL UNIQUE +); + CREATE TABLE IF NOT EXISTS exercises ( id SERIAL PRIMARY KEY, name VARCHAR(128) NOT NULL UNIQUE ); +CREATE TABLE IF NOT EXISTS exercises_categories ( + exercise_id INTEGER REFERENCES exercises (id), + category_id INTEGER REFERENCES categories (id), + PRIMARY KEY (exercise_id, category_id) +); + CREATE TABLE IF NOT EXISTS gyms ( id SERIAL PRIMARY KEY, name VARCHAR(128) NOT NULL UNIQUE @@ -52,19 +63,22 @@ BEGIN CREATE ROLE gym_tracker LOGIN; GRANT SELECT - ON TABLE exercises, gyms, gyms_records, records, workouts, workouts_exercises + ON categories, exercises, exercises_categories, gyms, gyms_records, + records, workouts, workouts_exercises TO gym_tracker; GRANT INSERT - ON TABLE exercises, gyms, gyms_records, records, workouts, workouts_exercises, workouts_gyms + ON categories, exercises, exercises_categories, gyms, gyms_records, + records, workouts, workouts_exercises, workouts_gyms TO gym_tracker; GRANT UPDATE - ON TABLE exercises, gyms, gyms_records, records + ON exercises, gyms, gyms_records, records TO gym_tracker; GRANT USAGE, SELECT - ON SEQUENCE exercises_id_seq, gyms_id_seq, workouts_id_seq + ON SEQUENCE categories_id_seq, exercises_id_seq, gyms_id_seq, + workouts_id_seq TO gym_tracker; /* Execute for the current database. */ diff --git a/drop.sql b/drop.sql index a9771bb..8d46528 100644 --- a/drop.sql +++ b/drop.sql @@ -1,4 +1,4 @@ -/* Copyright (c) 2023 Jakub Czajka +/* Copyright (c) 2023-2024 Jakub Czajka License: GPL-3.0 or later. */ DO $$ @@ -6,19 +6,22 @@ BEGIN IF EXISTS (SELECT * FROM pg_user WHERE usename = 'gym_tracker') THEN REVOKE SELECT - ON TABLE exercises, gyms, gyms_records, records, workouts, workouts_exercises + ON exercises, categories, exercises_categories, gyms, gyms_records, + records, workouts, workouts_exercises FROM gym_tracker; REVOKE INSERT - ON TABLE exercises, gyms, gyms_records, records, workouts, workouts_exercises, workouts_gyms + ON exercises, categories, exercises_categories, gyms, gyms_records, + records, workouts, workouts_exercises, workouts_gyms FROM gym_tracker; REVOKE UPDATE - ON TABLE exercises, gym, gyms_records, records + ON exercises, gym, gyms_records, records FROM gym_tracker; REVOKE USAGE, SELECT - ON SEQUENCE exercises_id_seq, gyms_id_seq, workouts_id_seq + ON SEQUENCE exercises_id_seq, categories_id_seq, gyms_id_seq, + workouts_id_seq FROM gym_tracker; EXECUTE @@ -36,4 +39,6 @@ DROP TABLE IF EXISTS records; DROP TABLE IF EXISTS gyms_records; DROP TABLE IF EXISTS workouts; DROP TABLE IF EXISTS gyms; +DROP TABLE IF EXISTS exercises_categories; +DROP TABLE IF EXISTS categories; DROP TABLE IF EXISTS exercises;