From 54c8a58e58bded8ccdcd6c531d24161040a439b1 Mon Sep 17 00:00:00 2001 From: amundson Date: Fri, 24 Jan 2020 12:22:46 -0700 Subject: [PATCH 1/2] Adding the initial create sql statement needed to get the db up and running --- Backend/src/main/resources/create.sql | 36 +++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Backend/src/main/resources/create.sql diff --git a/Backend/src/main/resources/create.sql b/Backend/src/main/resources/create.sql new file mode 100644 index 00000000..8ecf783b --- /dev/null +++ b/Backend/src/main/resources/create.sql @@ -0,0 +1,36 @@ +-- This creates the original database required for ideaLab +create sequence hibernate_sequence start 1 increment 1; +create table color_type (id serial not null, created_at timestamp, updated_at timestamp, available boolean not null, color varchar(255) not null, primary key (id)); +create table customer_info (id serial not null, created_at timestamp, updated_at timestamp, email varchar(254) not null, first_name varchar(254) not null, last_name varchar(254) not null, primary key (id)); +create table email_message (id serial not null, created_at timestamp, updated_at timestamp, email_message varchar(255), status varchar(255) not null, primary key (id)); +create table employee (id serial not null, created_at timestamp, updated_at timestamp, first_name varchar(254) not null, last_name varchar(254) not null, password varchar(255) not null, role varchar(255) not null, username varchar(254) not null, primary key (id)); +create table print_job (id serial not null, created_at timestamp, updated_at timestamp, comments varchar(255), email_hash varchar(254), file_path varchar(254), file_sharable_link varchar(254), status varchar(255) not null, fk_color_type_id int4 not null, fk_customer_info_id int4 not null, fk_employee_id int4 not null, primary key (id)); +create table print_job_aud (id int4 not null, rev int4 not null, revtype int2, comments varchar(255), email_hash varchar(255), file_path varchar(255), file_sharable_link varchar(255), status varchar(255), fk_color_type_id int4, fk_customer_info_id int4, fk_employee_id int4, primary key (id, rev)); +create table queue (id serial not null, created_at timestamp, updated_at timestamp, rank int8 not null, fk_print_job_id int4 not null, primary key (id)); +create table revinfo (rev int4 not null, revtstmp int8, primary key (rev)); +alter table if exists queue add constraint UK_kp5t2t9evuub0kg3qjp69b94c unique (fk_print_job_id); +alter table if exists print_job add constraint FK99v01thloyq28gjasmboxidob foreign key (fk_color_type_id) references color_type; +alter table if exists print_job add constraint FK3kqmfmhtcx6o4afnjm7hhj1d7 foreign key (fk_customer_info_id) references customer_info; +alter table if exists print_job add constraint FK9gyhrnjalygjlys5ax1lbh18t foreign key (fk_employee_id) references employee; +alter table if exists print_job_aud add constraint FKt12ekx6fgt7klxdgb9d5nawaw foreign key (rev) references revinfo; +alter table if exists queue add constraint FKsg4hqrp3p9kuww6pvxx11u3tk foreign key (fk_print_job_id) references print_job; +-- Create a list of base colors to be used +INSERT INTO color_type (color, available, created_at, updated_at) VALUES +('#FFFFFF', true, current_timestamp, current_timestamp), +('#FFCC00', true, current_timestamp, current_timestamp), +('#336600', true, current_timestamp, current_timestamp), +('#6600CC', true, current_timestamp, current_timestamp), +('#CC0000', true, current_timestamp, current_timestamp), +('#CC6600', true, current_timestamp, current_timestamp), +('#FF0099', true, current_timestamp, current_timestamp), +('#40E0D0', true, current_timestamp, current_timestamp), +('#996633', true, current_timestamp, current_timestamp), +('#800080', true, current_timestamp, current_timestamp), +('#000000', true, current_timestamp, current_timestamp); +-- Create a base admin employee with a username admin and a password of password +INSERT INTO employee (first_name, last_name, "password", "role", username, created_at, updated_at) VALUES +('admin','admin','$2a$10$riZO8iqbcCR1X/4fEgh0Au/VBNqgTOjVhZu9ZdlaMxztQEPYF2o8i','ADMIN','admin', current_timestamp, current_timestamp); +-- Create the email messages needed +INSERT INTO email_message (email_message, created_at, updated_at, status) VALUES + ('Your print job failed.', current_timestamp, current_timestamp, 'FAILED'), + ('Your print job was completed.', current_timestamp, current_timestamp, 'COMPLETED'); From 78dffaf9d41756bf96618016c6b4d19d29287be4 Mon Sep 17 00:00:00 2001 From: amundson Date: Fri, 24 Jan 2020 12:26:50 -0700 Subject: [PATCH 2/2] Changed some horrific color choices I made --- Backend/src/main/resources/create.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Backend/src/main/resources/create.sql b/Backend/src/main/resources/create.sql index 8ecf783b..e8c2950b 100644 --- a/Backend/src/main/resources/create.sql +++ b/Backend/src/main/resources/create.sql @@ -18,7 +18,7 @@ alter table if exists queue add constraint FKsg4hqrp3p9kuww6pvxx11u3tk foreign k INSERT INTO color_type (color, available, created_at, updated_at) VALUES ('#FFFFFF', true, current_timestamp, current_timestamp), ('#FFCC00', true, current_timestamp, current_timestamp), -('#336600', true, current_timestamp, current_timestamp), +('#008000', true, current_timestamp, current_timestamp), ('#6600CC', true, current_timestamp, current_timestamp), ('#CC0000', true, current_timestamp, current_timestamp), ('#CC6600', true, current_timestamp, current_timestamp), @@ -26,6 +26,7 @@ INSERT INTO color_type (color, available, created_at, updated_at) VALUES ('#40E0D0', true, current_timestamp, current_timestamp), ('#996633', true, current_timestamp, current_timestamp), ('#800080', true, current_timestamp, current_timestamp), +('#0000FF', true, current_timestamp, current_timestamp), ('#000000', true, current_timestamp, current_timestamp); -- Create a base admin employee with a username admin and a password of password INSERT INTO employee (first_name, last_name, "password", "role", username, created_at, updated_at) VALUES