Skip to content

Commit

Permalink
Added make_db script. Updated DB data and definitions.
Browse files Browse the repository at this point in the history
  • Loading branch information
davorg committed Jul 30, 2016
1 parent 5a966f8 commit 4a30a1c
Show file tree
Hide file tree
Showing 24 changed files with 157 additions and 32 deletions.
9 changes: 9 additions & 0 deletions 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
8 changes: 4 additions & 4 deletions 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);

1 change: 1 addition & 0 deletions 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,
Expand Down
9 changes: 9 additions & 0 deletions 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
8 changes: 4 additions & 4 deletions 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);

1 change: 1 addition & 0 deletions 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,
Expand Down
9 changes: 9 additions & 0 deletions 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
8 changes: 4 additions & 4 deletions 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);

1 change: 1 addition & 0 deletions 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,
Expand Down
9 changes: 9 additions & 0 deletions 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
8 changes: 4 additions & 4 deletions 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);

1 change: 1 addition & 0 deletions 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,
Expand Down
9 changes: 9 additions & 0 deletions 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
8 changes: 4 additions & 4 deletions 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);

1 change: 1 addition & 0 deletions 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,
Expand Down
9 changes: 9 additions & 0 deletions 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
8 changes: 4 additions & 4 deletions 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);

1 change: 1 addition & 0 deletions 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,
Expand Down
9 changes: 9 additions & 0 deletions 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
8 changes: 4 additions & 4 deletions 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);

1 change: 1 addition & 0 deletions 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,
Expand Down
9 changes: 9 additions & 0 deletions 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
50 changes: 46 additions & 4 deletions 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'));
4 changes: 4 additions & 0 deletions 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,
Expand Down

0 comments on commit 4a30a1c

Please sign in to comment.