diff --git a/mysql/sql/init.sql b/mysql/sql/init.sql index 8a9a1cb..5c88a66 100644 --- a/mysql/sql/init.sql +++ b/mysql/sql/init.sql @@ -25,7 +25,7 @@ CREATE TABLE guestbook ( */ CREATE TABLE teams ( - teamid INT UNSIGNED AUTO_INCREMENT, + teamid INT AUTO_INCREMENT, team_name VARCHAR(200) NOT NULL, write_permission BOOLEAN, PRIMARY KEY (teamid) @@ -79,7 +79,7 @@ CREATE TABLE projects_users ( CREATE TABLE tasks ( taskid INT UNSIGNED AUTO_INCREMENT, projectid INT UNSIGNED NOT NULL, - teamid INT UNSIGNED NULL, + teamid INT, title VARCHAR(200) NOT NULL, task_description VARCHAR(500), budget INT NOT NULL, @@ -87,6 +87,7 @@ CREATE TABLE tasks ( feedback VARCHAR(500) NULL, PRIMARY KEY (taskid), FOREIGN KEY (teamid) REFERENCES teams(teamid) + FOREIGN KEY (projectid) REFERENCES projects(projectid) ); CREATE TABLE task_files ( @@ -114,7 +115,7 @@ CREATE TABLE delivery ( ); CREATE TABLE task_offer ( - offerid INT UNSIGNED AUTO_INCREMENT, + offerid INT UNSIGNED AUTO_INCREMENT,1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`db`.`tasks`, CONSTRAINT `tasks_ibfk_1` FOREIGN KEY (`teamid`) REFERENCES `teams` (`teamid`)) taskid INT UNSIGNED NOT NULL, title VARCHAR(200) NOT NULL, price INT, @@ -135,6 +136,8 @@ insert into guestbook values (NULL, "Hello World"); insert into project_category values (NULL, "Test"); +insert into teams values (0, "NO TEAM", FALSE); + /* Create default database user */ diff --git a/src/app/models/database.py b/src/app/models/database.py index f1de688..1cb2a97 100644 --- a/src/app/models/database.py +++ b/src/app/models/database.py @@ -3,7 +3,7 @@ import mysql.connector db = mysql.connector.connect( user='root', password='root', - #host='10.5.0.5', # Docker address - host='0.0.0.0', # Local address + host='10.5.0.5', # Docker address + #host='0.0.0.0', # Local address database='db' ) diff --git a/src/app/models/project.py b/src/app/models/project.py index 5d4e1b3..235a334 100644 --- a/src/app/models/project.py +++ b/src/app/models/project.py @@ -119,7 +119,7 @@ def set_task(projectid, task_title, task_description, budget): :type budget: str """ cursor = db.cursor() - query = ("INSERT INTO tasks (projectid, title, task_description, budget, task_status) VALUES (\"" + + query = ("INSERT INTO tasks (teamid, projectid, title, task_description, budget, task_status) VALUES (1, \"" + projectid + "\", \"" + task_title + "\", \"" + task_description + "\", \"" + budget + "\", \"waiting for delivery\")") cursor.execute(query)