diff --git a/step05/db/make_db b/step05/db/make_db new file mode 100755 index 0000000..cce27b5 --- /dev/null +++ b/step05/db/make_db @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +echo "DROP DATABASE todo" | mysql -uroot +echo "CREATE DATABASE todo" | mysql -uroot +echo "GRANT ALL ON todo.* TO 'todouser'@'localhost' IDENTIFIED BY 'sekr1t'" | mysql -uroot +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.sql +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.dat diff --git a/step05/db/todo.dat b/step05/db/todo.dat index 45e9488..2513430 100644 --- a/step05/db/todo.dat +++ b/step05/db/todo.dat @@ -1,12 +1,12 @@ INSERT INTO item (title, description, due,done) -VALUES ('Todo Item One', 'Do something interesting','2016-02-10',1); +VALUES ('Todo Item One', 'Do something interesting','2016-07-10',1); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Two','Do something useful','2016-02-19',0); +VALUES ('Todo Item Two','Do something useful','2016-08-01',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Three','Do something exciting','2016-02-29',0); +VALUES ('Todo Item Three','Do something exciting','2016-08-20',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Four','Do something lucrative','2016-03-04',0); +VALUES ('Todo Item Four','Do something lucrative','2016-08-30',0); diff --git a/step05/db/todo.sql b/step05/db/todo.sql index da047c7..82bedce 100644 --- a/step05/db/todo.sql +++ b/step05/db/todo.sql @@ -1,3 +1,4 @@ +DROP TABLE IF EXISTS item; CREATE TABLE item ( id integer not null auto_increment primary key, title varchar(200) not null, diff --git a/step06/db/make_db b/step06/db/make_db new file mode 100755 index 0000000..cce27b5 --- /dev/null +++ b/step06/db/make_db @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +echo "DROP DATABASE todo" | mysql -uroot +echo "CREATE DATABASE todo" | mysql -uroot +echo "GRANT ALL ON todo.* TO 'todouser'@'localhost' IDENTIFIED BY 'sekr1t'" | mysql -uroot +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.sql +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.dat diff --git a/step06/db/todo.dat b/step06/db/todo.dat index 45e9488..2513430 100644 --- a/step06/db/todo.dat +++ b/step06/db/todo.dat @@ -1,12 +1,12 @@ INSERT INTO item (title, description, due,done) -VALUES ('Todo Item One', 'Do something interesting','2016-02-10',1); +VALUES ('Todo Item One', 'Do something interesting','2016-07-10',1); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Two','Do something useful','2016-02-19',0); +VALUES ('Todo Item Two','Do something useful','2016-08-01',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Three','Do something exciting','2016-02-29',0); +VALUES ('Todo Item Three','Do something exciting','2016-08-20',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Four','Do something lucrative','2016-03-04',0); +VALUES ('Todo Item Four','Do something lucrative','2016-08-30',0); diff --git a/step06/db/todo.sql b/step06/db/todo.sql index da047c7..82bedce 100644 --- a/step06/db/todo.sql +++ b/step06/db/todo.sql @@ -1,3 +1,4 @@ +DROP TABLE IF EXISTS item; CREATE TABLE item ( id integer not null auto_increment primary key, title varchar(200) not null, diff --git a/step07/db/make_db b/step07/db/make_db new file mode 100755 index 0000000..cce27b5 --- /dev/null +++ b/step07/db/make_db @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +echo "DROP DATABASE todo" | mysql -uroot +echo "CREATE DATABASE todo" | mysql -uroot +echo "GRANT ALL ON todo.* TO 'todouser'@'localhost' IDENTIFIED BY 'sekr1t'" | mysql -uroot +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.sql +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.dat diff --git a/step07/db/todo.dat b/step07/db/todo.dat index 45e9488..2513430 100644 --- a/step07/db/todo.dat +++ b/step07/db/todo.dat @@ -1,12 +1,12 @@ INSERT INTO item (title, description, due,done) -VALUES ('Todo Item One', 'Do something interesting','2016-02-10',1); +VALUES ('Todo Item One', 'Do something interesting','2016-07-10',1); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Two','Do something useful','2016-02-19',0); +VALUES ('Todo Item Two','Do something useful','2016-08-01',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Three','Do something exciting','2016-02-29',0); +VALUES ('Todo Item Three','Do something exciting','2016-08-20',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Four','Do something lucrative','2016-03-04',0); +VALUES ('Todo Item Four','Do something lucrative','2016-08-30',0); diff --git a/step07/db/todo.sql b/step07/db/todo.sql index da047c7..82bedce 100644 --- a/step07/db/todo.sql +++ b/step07/db/todo.sql @@ -1,3 +1,4 @@ +DROP TABLE IF EXISTS item; CREATE TABLE item ( id integer not null auto_increment primary key, title varchar(200) not null, diff --git a/step08/db/make_db b/step08/db/make_db new file mode 100755 index 0000000..cce27b5 --- /dev/null +++ b/step08/db/make_db @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +echo "DROP DATABASE todo" | mysql -uroot +echo "CREATE DATABASE todo" | mysql -uroot +echo "GRANT ALL ON todo.* TO 'todouser'@'localhost' IDENTIFIED BY 'sekr1t'" | mysql -uroot +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.sql +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.dat diff --git a/step08/db/todo.dat b/step08/db/todo.dat index 45e9488..2513430 100644 --- a/step08/db/todo.dat +++ b/step08/db/todo.dat @@ -1,12 +1,12 @@ INSERT INTO item (title, description, due,done) -VALUES ('Todo Item One', 'Do something interesting','2016-02-10',1); +VALUES ('Todo Item One', 'Do something interesting','2016-07-10',1); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Two','Do something useful','2016-02-19',0); +VALUES ('Todo Item Two','Do something useful','2016-08-01',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Three','Do something exciting','2016-02-29',0); +VALUES ('Todo Item Three','Do something exciting','2016-08-20',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Four','Do something lucrative','2016-03-04',0); +VALUES ('Todo Item Four','Do something lucrative','2016-08-30',0); diff --git a/step08/db/todo.sql b/step08/db/todo.sql index da047c7..82bedce 100644 --- a/step08/db/todo.sql +++ b/step08/db/todo.sql @@ -1,3 +1,4 @@ +DROP TABLE IF EXISTS item; CREATE TABLE item ( id integer not null auto_increment primary key, title varchar(200) not null, diff --git a/step09/db/make_db b/step09/db/make_db new file mode 100755 index 0000000..cce27b5 --- /dev/null +++ b/step09/db/make_db @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +echo "DROP DATABASE todo" | mysql -uroot +echo "CREATE DATABASE todo" | mysql -uroot +echo "GRANT ALL ON todo.* TO 'todouser'@'localhost' IDENTIFIED BY 'sekr1t'" | mysql -uroot +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.sql +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.dat diff --git a/step09/db/todo.dat b/step09/db/todo.dat index 45e9488..2513430 100644 --- a/step09/db/todo.dat +++ b/step09/db/todo.dat @@ -1,12 +1,12 @@ INSERT INTO item (title, description, due,done) -VALUES ('Todo Item One', 'Do something interesting','2016-02-10',1); +VALUES ('Todo Item One', 'Do something interesting','2016-07-10',1); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Two','Do something useful','2016-02-19',0); +VALUES ('Todo Item Two','Do something useful','2016-08-01',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Three','Do something exciting','2016-02-29',0); +VALUES ('Todo Item Three','Do something exciting','2016-08-20',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Four','Do something lucrative','2016-03-04',0); +VALUES ('Todo Item Four','Do something lucrative','2016-08-30',0); diff --git a/step09/db/todo.sql b/step09/db/todo.sql index da047c7..82bedce 100644 --- a/step09/db/todo.sql +++ b/step09/db/todo.sql @@ -1,3 +1,4 @@ +DROP TABLE IF EXISTS item; CREATE TABLE item ( id integer not null auto_increment primary key, title varchar(200) not null, diff --git a/step10/db/make_db b/step10/db/make_db new file mode 100755 index 0000000..cce27b5 --- /dev/null +++ b/step10/db/make_db @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +echo "DROP DATABASE todo" | mysql -uroot +echo "CREATE DATABASE todo" | mysql -uroot +echo "GRANT ALL ON todo.* TO 'todouser'@'localhost' IDENTIFIED BY 'sekr1t'" | mysql -uroot +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.sql +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.dat diff --git a/step10/db/todo.dat b/step10/db/todo.dat index 45e9488..2513430 100644 --- a/step10/db/todo.dat +++ b/step10/db/todo.dat @@ -1,12 +1,12 @@ INSERT INTO item (title, description, due,done) -VALUES ('Todo Item One', 'Do something interesting','2016-02-10',1); +VALUES ('Todo Item One', 'Do something interesting','2016-07-10',1); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Two','Do something useful','2016-02-19',0); +VALUES ('Todo Item Two','Do something useful','2016-08-01',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Three','Do something exciting','2016-02-29',0); +VALUES ('Todo Item Three','Do something exciting','2016-08-20',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Four','Do something lucrative','2016-03-04',0); +VALUES ('Todo Item Four','Do something lucrative','2016-08-30',0); diff --git a/step10/db/todo.sql b/step10/db/todo.sql index da047c7..82bedce 100644 --- a/step10/db/todo.sql +++ b/step10/db/todo.sql @@ -1,3 +1,4 @@ +DROP TABLE IF EXISTS item; CREATE TABLE item ( id integer not null auto_increment primary key, title varchar(200) not null, diff --git a/step11/db/make_db b/step11/db/make_db new file mode 100755 index 0000000..cce27b5 --- /dev/null +++ b/step11/db/make_db @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +echo "DROP DATABASE todo" | mysql -uroot +echo "CREATE DATABASE todo" | mysql -uroot +echo "GRANT ALL ON todo.* TO 'todouser'@'localhost' IDENTIFIED BY 'sekr1t'" | mysql -uroot +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.sql +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.dat diff --git a/step11/db/todo.dat b/step11/db/todo.dat index 45e9488..2513430 100644 --- a/step11/db/todo.dat +++ b/step11/db/todo.dat @@ -1,12 +1,12 @@ INSERT INTO item (title, description, due,done) -VALUES ('Todo Item One', 'Do something interesting','2016-02-10',1); +VALUES ('Todo Item One', 'Do something interesting','2016-07-10',1); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Two','Do something useful','2016-02-19',0); +VALUES ('Todo Item Two','Do something useful','2016-08-01',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Three','Do something exciting','2016-02-29',0); +VALUES ('Todo Item Three','Do something exciting','2016-08-20',0); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Four','Do something lucrative','2016-03-04',0); +VALUES ('Todo Item Four','Do something lucrative','2016-08-30',0); diff --git a/step11/db/todo.sql b/step11/db/todo.sql index da047c7..82bedce 100644 --- a/step11/db/todo.sql +++ b/step11/db/todo.sql @@ -1,3 +1,4 @@ +DROP TABLE IF EXISTS item; CREATE TABLE item ( id integer not null auto_increment primary key, title varchar(200) not null, diff --git a/step12/db/make_db b/step12/db/make_db new file mode 100755 index 0000000..cce27b5 --- /dev/null +++ b/step12/db/make_db @@ -0,0 +1,9 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +echo "DROP DATABASE todo" | mysql -uroot +echo "CREATE DATABASE todo" | mysql -uroot +echo "GRANT ALL ON todo.* TO 'todouser'@'localhost' IDENTIFIED BY 'sekr1t'" | mysql -uroot +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.sql +mysql -utodouser -psekr1t -Dtodo < $DIR/todo.dat diff --git a/step12/db/todo.dat b/step12/db/todo.dat index 45e9488..e99a6fd 100644 --- a/step12/db/todo.dat +++ b/step12/db/todo.dat @@ -1,12 +1,54 @@ +INSERT INTO tag (name) +VALUES ('something'); + +INSERT INTO tag (name) +VALUES ('interesting'); + +INSERT INTO tag (name) +VALUES ('useful'); + +INSERT INTO tag (name) +VALUES ('exciting'); + +INSERT INTO tag (name) +VALUES ('lucrative'); + INSERT INTO item (title, description, due,done) -VALUES ('Todo Item One', 'Do something interesting','2016-02-10',1); +VALUES ('Todo Item One', 'Do something interesting','2016-07-10',1); + +INSERT INTO item_tag (item_id, tag_id) +VALUES ((SELECT id FROM item WHERE title = 'Todo Item One'), + (SELECT id FROM tag WHERE name = 'something')); +INSERT INTO item_tag (item_id, tag_id) +VALUES ((SELECT id FROM item WHERE title = 'Todo Item One'), + (SELECT id FROM tag WHERE name = 'interesting')); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Two','Do something useful','2016-02-19',0); +VALUES ('Todo Item Two','Do something useful','2016-08-01',0); + +INSERT INTO item_tag (item_id, tag_id) +VALUES ((SELECT id FROM item WHERE title = 'Todo Item Two'), + (SELECT id FROM tag WHERE name = 'something')); +INSERT INTO item_tag (item_id, tag_id) +VALUES ((SELECT id FROM item WHERE title = 'Todo Item One'), + (SELECT id FROM tag WHERE name = 'useful')); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Three','Do something exciting','2016-02-29',0); +VALUES ('Todo Item Three','Do something exciting','2016-08-20',0); + +INSERT INTO item_tag (item_id, tag_id) +VALUES ((SELECT id FROM item WHERE title = 'Todo Item Three'), + (SELECT id FROM tag WHERE name = 'something')); +INSERT INTO item_tag (item_id, tag_id) +VALUES ((SELECT id FROM item WHERE title = 'Todo Item Three'), + (SELECT id FROM tag WHERE name = 'exciting')); INSERT INTO item (title, description, due,done) -VALUES ('Todo Item Four','Do something lucrative','2016-03-04',0); +VALUES ('Todo Item Four','Do something lucrative','2016-08-30',0); +INSERT INTO item_tag (item_id, tag_id) +VALUES ((SELECT id FROM item WHERE title = 'Todo Item Four'), + (SELECT id FROM tag WHERE name = 'something')); +INSERT INTO item_tag (item_id, tag_id) +VALUES ((SELECT id FROM item WHERE title = 'Todo Item Four'), + (SELECT id FROM tag WHERE name = 'lucrative')); diff --git a/step12/db/todo.sql b/step12/db/todo.sql index f8a522c..2fb4b6f 100644 --- a/step12/db/todo.sql +++ b/step12/db/todo.sql @@ -1,3 +1,7 @@ +DROP TABLE IF EXISTS item_tag; +DROP TABLE IF EXISTS item; +DROP TABLE IF EXISTS tag; + CREATE TABLE item ( id integer not null auto_increment primary key, title varchar(200) not null,