Table creation on longer tries to occur if it already exists.

This commit is contained in:
neviyn 2018-09-15 20:57:26 +01:00
parent 366ead48cf
commit 7e0d58200f
4 changed files with 6 additions and 5 deletions

1
.gitignore vendored
View File

@ -192,3 +192,4 @@ backend/src/main/resources/assets
frontend/node
!maven-wrapper.jar
dependency-reduced-pom.xml
*.db

View File

@ -13,12 +13,12 @@ import uk.co.neviyn.Observations.core.Observation;
@RegisterRowMapper(Observation.Mapper.class)
public interface ObservationDao {
@SqlUpdate("CREATE TABLE observations (id INTEGER PRIMARY KEY AUTO_INCREMENT, siteId INTEGER, tutorManyId INTEGER, " +
@SqlUpdate("CREATE TABLE IF NOT EXISTS observations (id INTEGER PRIMARY KEY, siteId INTEGER, tutorManyId INTEGER, " +
"observed TEXT, monitoring INTEGER, control INTEGER, conservatism INTEGER, teamwork INTEGER, knowledge INTEGER, " +
"rawData TEXT, date DATE)")
void createObservationTable();
@SqlUpdate("CREATE TABLE observation_tutor (tutorId INT NOT NULL, observationId INT NOT NULL, " +
@SqlUpdate("CREATE TABLE IF NOT EXISTS observation_tutor (tutorId INT NOT NULL, observationId INT NOT NULL, " +
"FOREIGN KEY (tutorID) REFERENCES tutor(id), FOREIGN KEY (observationId) REFERENCES observations(id))")
void createObservationTutorTable();

View File

@ -10,7 +10,7 @@ import uk.co.neviyn.Observations.core.Site;
@RegisterRowMapper(Site.Mapper.class)
public interface SiteDao {
@SqlUpdate("CREATE TABLE site (id INTEGER PRIMARY KEY AUTO_INCREMENT, name VARCHAR(100))")
@SqlUpdate("CREATE TABLE IF NOT EXISTS site (id INTEGER PRIMARY KEY, name VARCHAR(100))")
void createSiteTable();
@SqlQuery("SELECT * FROM site")

View File

@ -12,7 +12,7 @@ import uk.co.neviyn.Observations.core.Tutor;
@RegisterRowMapper(Tutor.Mapper.class)
public interface TutorDao {
@SqlUpdate("CREATE TABLE tutor (id INTEGER PRIMARY KEY AUTO_INCREMENT, " +
@SqlUpdate("CREATE TABLE IF NOT EXISTS tutor (id INTEGER PRIMARY KEY, " +
"name VARCHAR(100), site INT, FOREIGN KEY (site) REFERENCES site(id))")
void createTutorTable();