Wrapping up Positions for sprint
This commit is contained in:
@@ -14,7 +14,7 @@ namespace Swarmops.Database
|
||||
/// </summary>
|
||||
public static int DbVersionExpected
|
||||
{
|
||||
get { return 20; }
|
||||
get { return 22; }
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,4 +17,6 @@
|
||||
0017 - Added SetCashAdvanceAmountCents procedure [RF]
|
||||
0018 - Added "IsContractor" field to Payroll [RF]
|
||||
0019 - Added "Acting" field to PositionAssignments [RF]
|
||||
0020 - Added concurrency check to TerminatePositionAssignment [RF]
|
||||
0020 - Added concurrency check to TerminatePositionAssignment [RF]
|
||||
0021 - Added PositionCustomTitles and its stored procedures [RF]
|
||||
0022 - Added VolunteerPositions and its stored procedures [RF]
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
CREATE TABLE `PositionCustomTitles` (
|
||||
`PositionId` int(11) unsigned NOT NULL,
|
||||
`CustomTitle` varchar(128) NOT NULL,
|
||||
PRIMARY KEY (`PositionId`),
|
||||
KEY `Index_Title` (`CustomTitle`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
DROP procedure IF EXISTS `SetCustomPositionTitle`
|
||||
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
CREATE PROCEDURE `SetCustomPositionTitle`(
|
||||
IN positionId INT,
|
||||
IN customTitle VARCHAR(128)
|
||||
)
|
||||
BEGIN
|
||||
|
||||
IF ((SELECT COUNT(*) FROM PositionCustomTitles WHERE PositionCustomTitles.PositionId = positionId) = 0)
|
||||
THEN
|
||||
INSERT INTO PositionCustomTitles (PositionId,CustomTitle) VALUES (positionId,customTitle);
|
||||
ELSE
|
||||
UPDATE PositionCustomTitles SET PositionCustomTitles.CustomTitle=customTitle WHERE PositionCustomTitles.PositionId=positionId;
|
||||
END IF;
|
||||
|
||||
END
|
||||
@@ -0,0 +1,60 @@
|
||||
CREATE TABLE `VolunteerPositions` (
|
||||
`VolunteerPositionId` INT NOT NULL AUTO_INCREMENT,
|
||||
`VolunteerId` INT NOT NULL,
|
||||
`PositionId` INT NOT NULL,
|
||||
`GeographyId` INT NOT NULL,
|
||||
`Open` TINYINT NOT NULL DEFAULT '1',
|
||||
`Assigned` TINYINT NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`VolunteerPositionId`),
|
||||
INDEX `Index_Position` (`PositionId` ASC),
|
||||
INDEX `Index_Geography` (`GeographyId` ASC),
|
||||
INDEX `Index_Open` (`Open` ASC),
|
||||
INDEX `Index_Volunteer` (`VolunteerId` ASC))
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
DROP procedure IF EXISTS `CreateVolunteerPosition`
|
||||
|
||||
|
||||
#
|
||||
|
||||
CREATE PROCEDURE `CreateVolunteerPosition`(
|
||||
IN volunteerId INT,
|
||||
IN positionId INT,
|
||||
IN geographyId INT
|
||||
)
|
||||
BEGIN
|
||||
|
||||
INSERT INTO VolunteerPositions (VolunteerId,PositionId,GeographyId,Open,Assigned)
|
||||
VALUES (volunteerId,positionId,geographyId,1,0);
|
||||
|
||||
SELECT LAST_INSERT_ID() AS Identity;
|
||||
|
||||
END
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
DROP procedure IF EXISTS `CloseVolunteerPosition`
|
||||
|
||||
|
||||
#
|
||||
|
||||
|
||||
CREATE PROCEDURE `CloseVolunteerPosition`(
|
||||
volunteerPositionId INTEGER,
|
||||
assigned TINYINT
|
||||
)
|
||||
BEGIN
|
||||
|
||||
UPDATE VolunteerPositions
|
||||
SET VolunteerPositions.Open=0,VolunteerRoles.Assigned=assigned
|
||||
WHERE VolunteerPositions.VolunteerPositionId=volunteerPositionId AND VolunteerPositions.Open=1;
|
||||
|
||||
SELECT ROW_COUNT() AS RowsUpdated;
|
||||
|
||||
|
||||
END
|
||||
Reference in New Issue
Block a user