From 9143f771d6416fdc249868c5e4e42df102573be8 Mon Sep 17 00:00:00 2001 From: Jeremy Zongker Date: Fri, 5 Apr 2024 10:05:26 -0500 Subject: [PATCH] Added ministries to plans --- src/models/Plan.ts | 1 + src/repositories/PlanRepository.ts | 8 ++++---- tools/dbScripts/plans.mysql | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/models/Plan.ts b/src/models/Plan.ts index 94235ae..400bc7e 100644 --- a/src/models/Plan.ts +++ b/src/models/Plan.ts @@ -1,6 +1,7 @@ export class Plan { public id?: string; public churchId?: string; + public ministryId?: string; public name?: string; public serviceDate?: Date; public notes?: string; diff --git a/src/repositories/PlanRepository.ts b/src/repositories/PlanRepository.ts index 9d3fb1c..819041a 100644 --- a/src/repositories/PlanRepository.ts +++ b/src/repositories/PlanRepository.ts @@ -13,15 +13,15 @@ export class PlanRepository { private async create(plan: Plan) { plan.id = UniqueIdHelper.shortId(); - const sql = "INSERT INTO plans (id, churchId, name, serviceDate, notes) VALUES (?, ?, ?, ?, ?);"; - const params = [plan.id, plan.churchId, plan.name, plan.serviceDate, plan.notes]; + const sql = "INSERT INTO plans (id, churchId, ministryId, name, serviceDate, notes) VALUES (?, ?, ?, ?, ?, ?);"; + const params = [plan.id, plan.churchId, plan.ministryId, plan.name, plan.serviceDate, plan.notes]; await DB.query(sql, params); return plan; } private async update(plan: Plan) { - const sql = "UPDATE plans SET name=?, serviceDate=?, notes=? WHERE id=? and churchId=?"; - const params = [plan.name, plan.serviceDate, plan.notes, plan.id, plan.churchId]; + const sql = "UPDATE plans SET ministryId=?, name=?, serviceDate=?, notes=? WHERE id=? and churchId=?"; + const params = [plan.ministryId, plan.name, plan.serviceDate, plan.notes, plan.id, plan.churchId]; await DB.query(sql, params); return plan; } diff --git a/tools/dbScripts/plans.mysql b/tools/dbScripts/plans.mysql index 13aec99..b655166 100644 --- a/tools/dbScripts/plans.mysql +++ b/tools/dbScripts/plans.mysql @@ -1,6 +1,7 @@ CREATE TABLE `plans` ( `id` char(11) NOT NULL, `churchId` char(11) DEFAULT NULL, + `ministryId` char(11) DEFAULT NULL, `name` varchar(45) DEFAULT NULL, `serviceDate` date DEFAULT NULL, `notes` text,