From 3d2da6f81eddbbacf64929ee4b827ffd158396ec Mon Sep 17 00:00:00 2001 From: Immanuel Onyeka Date: Sat, 12 Nov 2022 15:47:54 -0500 Subject: [PATCH] Seed loan types --- migrations/0_29092022_create_main_tables.sql | 2 +- migrations/seed.sql | 22 +++++++++++++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/migrations/0_29092022_create_main_tables.sql b/migrations/0_29092022_create_main_tables.sql index 369f044..900f58f 100644 --- a/migrations/0_29092022_create_main_tables.sql +++ b/migrations/0_29092022_create_main_tables.sql @@ -14,7 +14,7 @@ CREATE TABLE branch ( CREATE TABLE user ( id INT AUTO_INCREMENT, - email VARCHAR(40) NOT NULL, + email VARCHAR(40) UNIQUE NOT NULL, first_name VARCHAR(30) NOT NULL, last_name VARCHAR(30) NOT NULL, password CHAR(64) NOT NULL, diff --git a/migrations/seed.sql b/migrations/seed.sql index 146306f..af0e4ea 100644 --- a/migrations/seed.sql +++ b/migrations/seed.sql @@ -1,10 +1,10 @@ -INSERT INTO branch +INSERT IGNORE INTO branch (type, num ) VALUES ('NMLS', 'abc123idk'), ('FSRA', 'another branch'); -INSERT INTO user ( +INSERT IGNORE INTO user ( first_name, last_name, password, @@ -52,7 +52,7 @@ INSERT INTO user ( 'Free' ); -INSERT INTO license ( +INSERT IGNORE INTO license ( user_id, type, num @@ -67,3 +67,19 @@ INSERT INTO license ( 'FSRA', '5234gsdf' ); + +INSERT IGNORE INTO loan_type ( + branch_id, + user_id, + name +) VALUES +( + (SELECT id FROM branch LIMIT 1), + NULL, + 'testType' +), +( + NULL, + (SELECT id FROM user WHERE email="manager@example.com" LIMIT 1), + 'manager idea' +);