Skip to content
Snippets Groups Projects
Commit c885b573 authored by Rhys Evans's avatar Rhys Evans
Browse files

removed sql database from main, connect using mariaDB, H2 database and firefoxDriver working

parent 2d2b33d7
No related branches found
No related tags found
No related merge requests found
Showing
with 259 additions and 314 deletions
......@@ -40,9 +40,12 @@ dependencies {
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6:3.1.1.RELEASE'
// https://mvnrepository.com/artifact/org.webjars/openlayers
implementation group: 'org.webjars', name: 'openlayers', version: '5.2.0'
testImplementation 'com.h2database:h2'
// testImplementation 'com.h2database:h2'
// https://mvnrepository.com/artifact/com.h2database/h2
testImplementation group: 'com.h2database', name: 'h2', version: '2.2.224'
testImplementation("io.github.bonigarcia:webdrivermanager:5.4.0")
testImplementation("io.github.bonigarcia:webdrivermanager:5.6.0")
//selenium
testImplementation group: 'net.sourceforge.htmlunit', name: 'htmlunit', version: '2.32'
testImplementation group: 'org.seleniumhq.selenium', name: 'selenium-java', version: '4.1.0'
......
......@@ -44,7 +44,7 @@ public class LandmarksController {
// converts valid response using Location constructor into a submittable format to the sql table
Location loc = new Location(landmarks.getLandmarkID(), landmarks.getLandmarkName(), landmarks.getLandmarkEmail(), landmarks.getLandmarkDescription(), landmarks.getLandmarkLocation(), landmarks.getTrailID(), false);
locationRepository.addLocation(loc); // adds valid landmark to locations table
ModelAndView modelAndView = new ModelAndView("redirect:/home");
ModelAndView modelAndView = new ModelAndView("redirect:/mobile-home");
return modelAndView;
}
......
......@@ -13,6 +13,8 @@ import org.springframework.security.provisioning.JdbcUserDetailsManager;
import org.springframework.security.provisioning.UserDetailsManager;
import org.springframework.security.web.AuthenticationEntryPoint;
import org.springframework.security.web.SecurityFilterChain;
import org.springframework.security.web.servlet.util.matcher.MvcRequestMatcher;
import org.springframework.web.servlet.handler.HandlerMappingIntrospector;
import javax.sql.DataSource;
......@@ -21,14 +23,20 @@ import javax.sql.DataSource;
@EnableWebSecurity
public class SecurityConfiguration {
/* Configures the longin features and tracks logged on users on the page */
// used - https://stackoverflow.com/questions/77745122/security-filter-configuration-not-working-after-upgrade-to-spring-boot-3 to fix issue
@Bean
public MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
return new MvcRequestMatcher.Builder(introspector);
}
@Bean
public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception {
public SecurityFilterChain securityFilterChain(MvcRequestMatcher.Builder mvc,HttpSecurity http) throws Exception {
http
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests((requests) -> requests
.requestMatchers("/user/**", "/userProfile").authenticated()
.requestMatchers(mvc.pattern("/user/**"), mvc.pattern("/userProfile")).authenticated()
.anyRequest().permitAll()
)
......
spring.datasource.url=jdbc:mariadb://localhost:3306/towns
spring.datasource.username=root
spring.datasource.password=comsc
#spring.sql.init.mode=always
#spring.sql.init.data-locations=classpath:data.sql, classpath:/static/sql/user-data.sql, classpath:/static/sql/user-progress-data.sql
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
spring.datasource.password=password
spring.datasource.driver-class-name=org.h2.Driver
spring.sql.init.platform=mock
spring.sql.init.mode=always
spring.autoconfigure.exclude=
spring.datasource.url=jdbc:mariadb://localhost:3306/towns
spring.datasource.username=root
spring.datasource.password=comsc
spring.sql.init.mode=always
spring.sql.init.data-locations=classpath:data.sql, classpath:/static/sql/user-data.sql, classpath:/static/sql/user-progress-data.sql
spring.profiles.active=dev
\ No newline at end of file
/* 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 locationCoordinates;
drop table if exists locations;
drop table if exists trails;
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 varchar(128) primary key,
trailName varchar(128),
trailNumber varchar(128),
city varchar(128)
) engine=InnoDB;
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),
locationApproved boolean
) engine=InnoDB;
CREATE TABLE IF NOT EXISTS users (
username varchar(30) primary key NOT NULL,
id bigint auto_increment unique, /*DEPRECATED COLUMN, LEFT IN WHILE SOME OTHER FUNCTIONS STILL USE IT*/
email varchar(128),
password varchar(30) NOT NULL,
enabled boolean default true
);
CREATE TABLE IF NOT EXISTS authorities (
id bigint primary key auto_increment NOT NULL,
username varchar(30) NOT NULL ,
authority varchar(45) NOT NULL
);
CREATE TABLE IF NOT EXISTS packs (
id bigint auto_increment primary key,
name varchar(20) NOT NULL,
description text
);
CREATE TABLE IF NOT EXISTS stickers (
id bigint auto_increment primary key,
packID bigint NOT NULL,
FOREIGN KEY (packID) REFERENCES packs(id)
ON DELETE CASCADE
ON UPDATE RESTRICT,
stickerID bigint NOT NULL, /*STICKER ID NUMBER WITHIN ITS OWN PACK*/
name varchar(30) NOT NULL,
description text NOT NULL,
rarity tinyint
);
CREATE TABLE IF NOT EXISTS stickerProgress (
id bigint auto_increment primary key,
username varchar(30) NOT NULL,
FOREIGN KEY (username) REFERENCES users(username)
ON DELETE CASCADE
ON UPDATE RESTRICT,
packID bigint NOT NULL,
FOREIGN KEY (packID) REFERENCES packs(id)
ON DELETE CASCADE
ON UPDATE RESTRICT,
stickerID bigint NOT NULL,
FOREIGN KEY (stickerID) REFERENCES stickers(id)
ON DELETE CASCADE
ON UPDATE RESTRICT
);
create table if not exists locationCoordinates
(
locationCoordID bigint auto_increment primary key,
locationID bigint,
Foreign Key (locationID) REFERENCES locations(locationID)
ON DELETE CASCADE
ON UPDATE RESTRICT,
locationCoordsLat DECIMAL(8,6),
locationCoordsLong DECIMAL(8,6)
)engine=InnoDB;
create table if not exists townsWithTrails
(
townID bigint auto_increment primary key,
townName varchar(128),
townCentreCoordsLat varchar(128),
townCentreCoordsLong varchar(128),
townUppermostCoordsLat varchar(128),
townLowermostCoordsLat varchar(128),
townLeftmostCoordsLong varchar(128),
townRightmostCoordsLong varchar(128)
)engine=InnoDB;
create table if not exists localAuthority
(
localAuthorityID bigint auto_increment primary key,
localAuthorityName varchar(250),
address1 varchar(250),
address2 varchar(250),
city varchar(100),
county varchar(75),
postcode varchar(15),
website varchar(250)
) engine=InnoDB;
create table if not exists businesses
(
businessID bigint auto_increment primary key,
businessName varchar(250),
address1 varchar(250),
address2 varchar(250),
city varchar(100),
county varchar(75),
postcode varchar(15),
website varchar(250)
) engine=InnoDB;
......@@ -9,17 +9,26 @@ import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.web.servlet.MockMvc;
@SpringBootTest
@AutoConfigureMockMvc
@ActiveProfiles("dev")
public class ContainerMockMVCTests {
@Autowired
private MockMvc mockMvc;
@Test
public void a_testGreeting() throws Exception {
this.mockMvc.perform(get("/home")).andDo(print()).andExpect(status().isOk())
.andExpect(content().string(containsString("VZTA Smart Towns - Trails")));
}
@Test
public void a_testGreeting2() throws Exception {
this.mockMvc.perform(get("/mobile-home")).andDo(print()).andExpect(status().isOk())
.andExpect(content().string(containsString("Welcome to VZTA Smart Towns!")));
}
}
package Team5.SmartTowns;
import org.junit.jupiter.api.AfterEach;
//import org.junit.jupiter.api.BeforeAll;
//import org.junit.jupiter.api.BeforeEach;
import org.junit.After;
import org.junit.Before;
//import org.junit.Test; //- using this stops initialisation error, and runs properly, but breaks firefox driver
import org.junit.jupiter.api.Test; //works but initialisation error
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.runner.RunWith;
import org.openqa.selenium.By;
......@@ -15,6 +24,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.annotation.Profile;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.test.context.junit4.SpringRunner;
import io.github.bonigarcia.wdm.WebDriverManager;
......@@ -23,9 +33,10 @@ import io.github.bonigarcia.wdm.WebDriverManager;
import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertEquals;
@RunWith(SpringRunner.class)
//@RunWith(SpringRunner.class)
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@ActiveProfiles("test")
//@ActiveProfiles("test")
public class FirefoxDriverPagesTests {
@Value("${local.server.port}")
private int port;
......@@ -42,6 +53,7 @@ public class FirefoxDriverPagesTests {
FirefoxOptions options = new FirefoxOptions();
options.addArguments("--headless");
webDriver = new FirefoxDriver(options);
// webDriver = new FirefoxDriver();
}
@AfterEach
void teardown() {
......@@ -49,15 +61,15 @@ public class FirefoxDriverPagesTests {
}
// @Test
// public void pageSetupTest() {
// }
@Test
public void pageSetupTest() {
}
@Test
public void testHomePageContents() {
this.webDriver.get("http://localhost:" + Integer.toString(port) + "/mobile-home");
assertEquals(1,1);
// assertTrue(webDriver.findElement(By.cssSelector("main")).getText().contains("Welcome to VZTA Smart Towns!"));
// assertEquals(1,1);
assertTrue(webDriver.findElement(By.cssSelector("main")).getText().contains("Welcome to VZTA Smart Towns!"));
}
......
package Team5.SmartTowns;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Profile;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.sql.DataSource;
@Configuration
@EnableJpaRepositories(basePackages = {
"org.baeldung.repository",
"org.baeldung.boot.repository"
})
@EnableTransactionManagement
public class H2TestProfileJPAConfig {
@Bean
@Profile("test")
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.h2.Driver");
dataSource.setUrl("jdbc:h2:mem:db;DB_CLOSE_DELAY=-1");
dataSource.setUsername("sa");
dataSource.setPassword("password");
return dataSource;
}
// configure entityManagerFactory
// configure transactionManager
// configure additional Hibernate properties
}
//package Team5.SmartTowns;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Import;
//import org.springframework.context.annotation.Profile;
//import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
//import org.springframework.jdbc.datasource.DriverManagerDataSource;
//import org.springframework.transaction.annotation.EnableTransactionManagement;
//
//
//import javax.sql.DataSource;
//
//@Configuration
//@EnableJpaRepositories(basePackages = {
// "org.baeldung.repository",
// "org.baeldung.boot.repository"
//})
//@EnableTransactionManagement
//public class H2TestProfileJPAConfig {
//
// @Bean
// @Profile("test")
// public DataSource dataSource() {
// DriverManagerDataSource dataSource = new DriverManagerDataSource();
// dataSource.setDriverClassName("org.h2.Driver");
// dataSource.setUrl("jdbc:h2:mem:db;DB_CLOSE_DELAY=-1");
// dataSource.setUsername("sa");
// dataSource.setPassword("password");
//
// return dataSource;
// }
//
// // configure entityManagerFactory
// // configure transactionManager
// // configure additional Hibernate properties
//}
package Team5.SmartTowns;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class JUnitSimpleTests {
@Autowired
private Environment environment;
@Test
void aaa() {
assertEquals(1, 1);
}
@Test
void aaa(){
assertEquals(1,1);
void contextLoads() {
assertThat(environment.getActiveProfiles()).contains("test");
}
}
spring.datasource.url=jdbc:mariadb://localhost:3306/towns
spring.datasource.username=root
spring.datasource.password=comsc
#spring.sql.init.mode=always
#spring.sql.init.data-locations=classpath:data.sql, classpath:/static/sql/user-data.sql, classpath:/static/sql/user-progress-data.sql
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
spring.datasource.password=password
spring.datasource.driver-class-name=org.h2.Driver
spring.sql.init.platform=h2
spring.h2.console.enabled=true
#spring.jpa.hibernate.ddl-auto=none
spring.jpa.generate-ddl=false
spring.jpa.defer-datasource-initialization=true
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
#org.springframework.jdbc.datasource.init=debug
#org.springframework.test.context.jdbc=debug
#spring.sql.init.data-locations=classpath:schema-h2.sql, classpath:data-h2.sql
\ No newline at end of file
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
spring.datasource.password=password
spring.datasource.driver-class-name=org.h2.Driver
spring.sql.init.mode=always
\ No newline at end of file
#spring.datasource.url=jdbc:h2:mem:testdb
#spring.datasource.username=sa
#spring.datasource.password=password
#spring.datasource.driver-class-name=org.h2.Driver
#spring.sql.init.mode=always
spring.profiles.active=test
\ No newline at end of file
delete from trails;
insert into trails ( trailID, trailName, trailNumber, city) value ( 0101,'Caerphilly Castle Trail','0101', 'Caerphilly');
insert into trails ( trailID, trailName, trailNumber, city) value ( 0102,'Caerphilly Pub Trail','0102', 'Caerphilly');
insert into trails ( trailID, trailName, trailNumber, city) value ( 0103,'Caerphilly Heritage Trail','0103', 'Caerphilly');
insert into trails ( trailID, trailName, trailNumber, city) value ( 0201,'Risca Heritage Trail','0201', 'Risca');
insert into trails ( trailID, trailName, trailNumber, city) value ( 0301,'Penarth Esplanade Trail','0301', 'Penarth');
delete from locations;
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'St Cenydd','','Location description here','Caerphilly',0101, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Castle','','Location description here','Caerphilly',0101, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Medieval Trades','','Location description here','Caerphilly',0101, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Queen''s War','','Location description here','Caerphilly',0101, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Green Lady','','Location description here','Caerphilly',0101, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Armoury','','Location description here','Caerphilly',0101, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Architecture','','Location description here','Caerphilly',0101, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( '21st Century Landmark','','Location description here','Caerphilly',0101, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'JD Wetherspoons-Malcolm Uphill','','Location description here','Caerphilly',0102, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Cwtch','','Location description here','Caerphilly',0102, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Conservative Club','','Location description here','Caerphilly',0102, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The King''s Arms','','Location description here','Caerphilly',0102, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Caerphilly Bus Station','','Location description here','Caerphilly',0103, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Medieval Courthouse','','Location description here','Caerphilly',0103, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ('Caerphilly Castle','','Location description here','Caerphilly',0103, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Ty Vaughan House','','Location description here','Caerphilly',0103, false);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Risca Colliery','','Location description here','Risca',0201, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'Black Vein Colliery Disaster','','Location description here','Risca',0201, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Esplanade','','Location description here','Penarth',0301, true);
insert into locations ( locationName , locationEmail,locationDescription,locationPlace, locationTrailID, locationApproved) value ( 'The Old Swimming Baths','','Location description here','Penarth',0301, true);
DELETE FROM packs;
INSERT INTO packs (name, description) VALUE ('Wales Football Team', 'Pack of Welsh Football Players in the National Team');
INSERT INTO packs (name, description) VALUE ('Wales Rugby Team', 'Pack of Welsh Rugby Players in the National Team');
INSERT INTO packs (name, description) VALUE ('Welsh Heritage', 'Pack About Welsh Heritage');
DELETE FROM stickers;
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (1, 1, 'wayne_hennessey', 'Wales Football Team Player', '2');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (1, 2, 'neco_williams', 'Wales Football Team Player', '2');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (1, 3, 'joe_morrell', 'Wales Football Team Player', '2');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (1, 4, 'ethan_ampadu', 'Wales Football Team Player', '2');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (1, 5, 'connor_roberts', 'Wales Football Team Player', '2');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (2, 1, 'Taine_Basham', 'Wales Rugby Team Player', '1');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (2, 2, 'Adam Beard', 'Wales Rugby Team Player', '1');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (2, 3, 'Elliot Dee', 'Wales Rugby Team Player', '1');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (2, 4, 'Corey Domachowski', 'Wales Rugby Team Player', '1');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (2, 5, 'Ryan Elias', 'Wales Rugby Team Player', '1');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (3, 1, 'Welsh Lady', 'Welsh Heritage', '1');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (3, 2, 'Welsh Outline', 'Welsh Heritage', '1');
INSERT INTO stickers (packID, stickerID, name, description, rarity) VALUE (3, 3, 'Welsh Spoon', 'Welsh Heritage', '1');
delete from locationCoordinates;
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (2, 51.57623, -3.21910 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (3, 51.575372, -3.219186);
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (4, 51.576363, -3.220712 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (9, 51.57239, -3.21992);
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (10, 51.57230, -3.21938 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (13, 51.57168, -3.21861);
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (14, 51.57465, -3.22022 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (17, 51.61117, -3.10198 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (18, 51.61655, -3.12371 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (19, 51.43484, -3.16492 );
insert into locationCoordinates(locationID, locationCoordsLat, locationCoordsLong) value (20, 51.43547, -3.16789 );
delete from localauthority;
insert into localauthority ( localAuthorityName, address1, address2, city, county, postcode, website) value ( 'Caerphilly County Borough Council', 'Tredomen Park','', 'Ystrad Mynach, Hengoed', '', 'CF82 7PG', 'https://www.caerphilly.gov.uk/main.aspx?lang=en-GB');
insert into localauthority ( localAuthorityName, address1, address2, city, county, postcode, website) value ( 'Risca Town Council', 'Unit B, 75 Tredegar Street', '', 'Risca', '', 'NP11 6BW', 'https://www.riscatowncouncil.org.uk/');
insert into localauthority ( localAuthorityName, address1, address2, city, county, postcode, website) value ( 'Penarth Town Council West House', 'Stanwell Road', '', 'Penarth', '', 'CF64 2YG', 'https://www.penarthtowncouncil.gov.uk/your-council/');
delete from businesses;
insert into businesses ( businessName, address1, address2, city, county, postcode, website) value ( 'Caerphilly Castle', 'Castle Street','', 'Caerphilly', '', 'CF836 1JD', 'https://cadw.gov.wales/visit/places-to-visit/caerphilly-castle');
insert into businesses ( businessName, address1, address2, city, county, postcode, website) value ( 'Risca Museum', 'Grove Road', '', 'Risca', '', 'NP11 6GN', 'https://riscamuseum.wales/');
insert into businesses ( businessName, address1, address2, city, county, postcode, website) value ( 'Penarth Pier Pavillion Cinema', 'Windsor Court', 'The Esplanade', 'Penarth', '', 'CF64 3AU', 'https://www.valeofglamorgan.gov.uk/en/enjoying/Coast-and-Countryside/Dog-Beach-Ban.aspx');
delete from townsWithTrails;
insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Caerphilly', '51.57903','-3.22075 ','51.60418','51.55093','-3.25222','-3.17696');
insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Risca','51.61195','-3.09648','51.63039','51.59175','-3.12129','-3.06438');
insert into townsWithTrails (townName, townCentreCoordsLat, townCentreCoordsLong, townUppermostCoordsLat, townLowermostCoordsLat, townLeftmostCoordsLong, townRightmostCoordsLong) value ('Penarth','51.43893','-3.17354','51.44878','51.41233','-3.20271','-3.16005');
-- delete from dragonstale;
-- insert into dragonstale(landmarkID, landmarkName, landmarkDescription, imgPath) value (1, 'A scent of...Dragon', 'The Dragon has been spotted near by, find the QR code to continue', '~/images/dragonstale/DTLM1.png');
\ No newline at end of file
drop table if exists locationCoordinates;
drop table if exists locations;
drop table if exists trails;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS stickerProgress;
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 varchar(128) primary key,
trailName varchar(128),
trailNumber varchar(128),
city varchar(128)
) engine=InnoDB;
CREATE TABLE IF NOT EXISTS trails
(trailID varchar(128) primary key,trailName varchar(128),trailNumber varchar(128),city varchar(128)
);
create table if not exists locations
(
locationID bigint auto_increment primary key,
(locationID bigint auto_increment primary key,
locationName varchar(128),
locationEmail varchar(128),
locationDescription longtext,
locationPlace varchar(255),
locationTrailID varchar(128),
locationApproved boolean
) engine=InnoDB;
);
CREATE TABLE IF NOT EXISTS users (
......@@ -91,7 +88,7 @@ create table if not exists locationCoordinates
locationCoordsLong DECIMAL(8,6)
)engine=InnoDB;
);
......@@ -106,7 +103,7 @@ create table if not exists townsWithTrails
townLeftmostCoordsLong varchar(128),
townRightmostCoordsLong varchar(128)
)engine=InnoDB;
);
create table if not exists localAuthority
......@@ -119,7 +116,7 @@ create table if not exists localAuthority
county varchar(75),
postcode varchar(15),
website varchar(250)
) engine=InnoDB;
);
create table if not exists businesses
......@@ -132,6 +129,6 @@ create table if not exists businesses
county varchar(75),
postcode varchar(15),
website varchar(250)
) engine=InnoDB;
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment