From e847822d48612176a331b30c2f8e4c17f92d436d Mon Sep 17 00:00:00 2001 From: Gabriel Copat <copatg@cardiff.ac.uk> Date: Sat, 9 Dec 2023 10:58:30 +0000 Subject: [PATCH] Adjusted schema.sql to be more readable; --- .../rewards/RewardsRepositoryJDBC.java | 1 - src/main/resources/schema.sql | 59 +++++++++---------- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/src/main/java/Team5/SmartTowns/rewards/RewardsRepositoryJDBC.java b/src/main/java/Team5/SmartTowns/rewards/RewardsRepositoryJDBC.java index 65eaa984..4bda88a5 100644 --- a/src/main/java/Team5/SmartTowns/rewards/RewardsRepositoryJDBC.java +++ b/src/main/java/Team5/SmartTowns/rewards/RewardsRepositoryJDBC.java @@ -10,7 +10,6 @@ import java.util.List; @Repository public class RewardsRepositoryJDBC implements RewardsRepository { private final JdbcTemplate jdbc; - private RowMapper<Badge> badgeMapper; private RowMapper<Sticker> stickerMapper; private RowMapper<Pack> packMapper; diff --git a/src/main/resources/schema.sql b/src/main/resources/schema.sql index e696d309..8069cb3f 100644 --- a/src/main/resources/schema.sql +++ b/src/main/resources/schema.sql @@ -1,47 +1,49 @@ -drop table if exists trails; -create table if not exists trails -( +/* DELETES AND RECREATES DATABASE EVERY TIME THE SYSTEM IS BOOTED*/ +DROP DATABASE IF EXISTS towns; +CREATE DATABASE IF NOT EXISTS towns; +USE towns; +/****************************************************************/ + +/* DROPS ALL TABLES IF THEY EXIST (they wont but just in case) */ +DROP TABLE IF EXISTS trails; +DROP TABLE IF EXISTS locations; +DROP TABLE IF EXISTS users; +DROP TABLE IF EXISTS stickers; +DROP TABLE IF EXISTS packs; +DROP TABLE IF EXISTS stickerProgress; +/****************************************************************/ + +/* CREATES ALL TABLES */ + +CREATE TABLE IF NOT EXISTS trails ( trailID bigint auto_increment primary key, name varchar(128) -) engine=InnoDB; +); -drop table if exists locations; - -create table if not exists locations -( +CREATE TABLE IF NOT EXISTS locations ( locationID bigint auto_increment primary key, locationName varchar(128), locationEmail varchar(128), locationDescription longtext, locationPlace varchar(255), locationTrailID varchar(128) -) engine=InnoDB; - - -drop table if exists users; -drop table if exists stickers; -drop table if exists packs; -drop table if exists stickerProgress; +); -create table if not exists users -( +CREATE TABLE IF NOT EXISTS users ( id bigint auto_increment primary key, email varchar(128) NOT NULL , name varchar(30), dragonProgress int, dragonsLandmarkIDs longtext -) engine=InnoDB; +); - -create table if not exists packs -( +CREATE TABLE IF NOT EXISTS packs ( id bigint auto_increment primary key, name varchar(20), description text -) engine=InnoDB; +); -create table if not exists stickers -( +CREATE TABLE IF NOT EXISTS stickers ( id bigint auto_increment primary key, packID bigint, FOREIGN KEY (packID) REFERENCES packs(id) @@ -51,14 +53,11 @@ create table if not exists stickers name varchar(30), description text, rarity tinyint +); -) engine=InnoDB; - -create table if not exists stickerProgress -( +CREATE TABLE IF NOT EXISTS stickerProgress ( id bigint auto_increment primary key, userID bigint, packID bigint, stickerID bigint - -) engine=InnoDB; +); -- GitLab