package DB::Test::OrderProcess;
use strict;
use warnings;
use parent 'DB::Test';

sub cart {
	"CREATE TABLE cart (
		cartitemID INTEGER PRIMARY KEY,
		orderID INTEGER NOT NULL,
		productID INTEGER NOT NULL,
		vendorID INTEGER NOT NULL,
		partnumber VARCHAR NOT NULL,
		qty INTEGER NOT NULL
	)"

}

sub orders {
	"CREATE TABLE orders (
		orderID INTEGER PRIMARY KEY,
		status VARCHAR NOT NULL
	)"
}
	
sub brand {
	"CREATE TABLE brand (
		brandID INTEGER PRIMARY KEY,
		genuine INTEGER NOT NULL,
		name TEXT NOT NULL
	)"
}

sub product {
	"CREATE TABLE product (
		productID INTEGER PRIMARY KEY,
		partnumber VARCHAR NOT NULL,
		brandID INTEGER NOT NULL,
		type VARCHAR NOT NULL,
		UPCCode TEXT
	)"
}

sub productVendor {
	"CREATE TABLE productVendor (
		productID INTEGER NOT NULL,
		vendorID INTEGER NOT NULL,
		optInMethod VARCHAR,
		PRIMARY KEY(productID, vendorID)
	)"
}	

sub vendor {
	"CREATE TABLE vendor (
		vendorID INTEGER PRIMARY KEY,
		optInMethod VARCHAR
	)"
}

sub productOem {
	"CREATE TABLE productOem (
		productID INTEGER NOT NULL,
		barCode VARCHAR NOT NULL,
		PRIMARY KEY( productID, barCode )
	)"
}

sub cartComponentPicked {
	"CREATE TABLE cartComponentPicked (
		cartitemID INTEGER NOT NULL,
		productID INTEGER NOT NULL,
		vendorID INTEGER NOT NULL,
		required INTEGER NOT NULL,
		PRIMARY KEY(cartitemID, productID)
	)" 
}

sub orderShipping {
	"CREATE TABLE orderShipping (
		orderID INTEGER PRIMARY KEY,
		shippingServiceCode VARCHAR NOT NULL
	)"
}

sub shippingService {
	"CREATE TAbLE shippingService (
		shippingServiceCode VARCHAR PRIMARY KEY
	)"
}

sub init_db {
	my $class = shift;
	my ($dbh) = @_;
	$class->SUPER::init_db( $dbh );
	for my $table (qw/
		cart
		orders
		brand
		product
		productVendor
		vendor
		productOem
		cartComponentPicked
		orderShipping
		shippingService
	/) {
		$class->add_table( $dbh, $table );
	}
	1;
}

1;
