Added test cases and test data for the database layer.

This commit is contained in:
Jonathan Bernard
2015-03-07 14:20:06 -06:00
parent c323df219e
commit b6536c0794
7 changed files with 297 additions and 16 deletions

View File

@ -0,0 +1,8 @@
-- DROP DATABASE IF EXISTS nlsongs;
CREATE DATABASE nlsongs
ENCODING = 'UTF8'
LC_COLLATE = 'en_US.UTF-8'
LC_CTYPE = 'en_US.UTF-8'
CONNECTION LIMIT = 1;
\c nlsongs

View File

@ -3,21 +3,13 @@
--
-- PostgreSQL database creation sript.
-- DROP DATABASE IF EXISTS nlsongs;
CREATE DATABASE nlsongs
ENCODING = 'UTF8'
LC_COLLATE = 'en_US.UTF-8'
LC_CTYPE = 'en_US.UTF-8'
CONNECTION LIMIT = 1;
\c nlsongs
-- Services table
DROP TABLE IF EXISTS services;
CREATE TABLE IF NOT EXISTS services (
id SERIAL,
date DATE NOT NULL,
service_type VARCHAR(16) DEFAULT NULL,
CONSTRAINT uc_serviceTypeAndDate UNIQUE (date, service_type),
PRIMARY KEY (id));
@ -27,6 +19,7 @@ CREATE TABLE IF NOT EXISTS songs (
id SERIAL,
name VARCHAR(128) NOT NULL,
artists VARCHAR(256) DEFAULT NULL,
CONSTRAINT uc_songNameAndArtist UNIQUE (name, artists),
PRIMARY KEY (id));
@ -42,8 +35,8 @@ CREATE TABLE IF NOT EXISTS performances (
guitarist VARCHAR(64) DEFAULT NULL,
leader VARCHAR(64) DEFAULT NULL,
PRIMARY KEY (service_id, song_id),
FOREIGN KEY (service_id) REFERENCES services (id),
FOREIGN KEY (song_id) REFERENCES songs (id));
FOREIGN KEY (service_id) REFERENCES services (id) ON DELETE CASCADE,
FOREIGN KEY (song_id) REFERENCES songs (id) ON DELETE CASCADE);
DROP TABLE IF EXISTS users;

View File

@ -0,0 +1,5 @@
DROP TABLE tokens;
DROP TABLE users;
DROP TABLE performances;
DROP TABLE songs;
DROP TABLE services;