Create the Tables
$ mysql -u hoge -p depot_development < /path/to/dionea/sample/rails/db/create.sql
- create.sql -
create table products(
id int not null auto_increment,
title varchar(100) not null,
description text not null,
image_uri varchar(200) not null,
price decimal(10,2) not null,
date_available datetime not null,
primary key(id)
);
create table orders(
id int not null auto_increment,
name varchar(100) not null,
email varchar(255) not null,
address text not null,
pay_type char(10) not null,
shipped_at datetime null,
primary key (id)
);
create table users(
id int not null auto_increment,
name varchar(100) not null,
hashed_password char(40) null,
primary key(id)
);
create table line_items(
id int not null auto_increment,
product_id int not null,
order_id int not null,
quantity int not null,
unit_price decimal(10,2) not null,
constraint fk_items_product foreign key(product_id) references products(id),
constraint fk_items_order foreign key(order_id) references orders(id),
primary key (id)
);
Create the DB datas
$ mysql -u hoge -p depot_development < /path/to/dionea/sample/rails/db/insert.sql
- insert.sql -
lock tables products write;
insert into products values(null,
"Pragmatic Unit Testing (C#)",
"Pragmatic programmers ... ",
"/images/sk_utc_small.jpg",
"29.95",
"2006-03-13 22:05:00");
insert into products values(null,
"Pragmatic Project Automation",
"A really great read!",
"/images/sk_auto_small.jpg",
"29.95",
"2004-12-25 05:00:00");
insert into products values(null,
"Pragmatic Versin Control",
"A really controlled read!",
"/images/sk_svn_small.jpg",
"29.95",
"2004-12-25 05:00:00");
unlock tables;