Skip to content

Commit 589f7df

Browse files
authored
Merge pull request #3361 from TechnologyEnhancedLearning/Develop/feature/TD-5638-Remove-custom-administrator-titles
TD-5638 -Remove custom administrator titles and revert back to nominated supervisor and supervisor terms
2 parents 58002c9 + 9aa1d4f commit 589f7df

20 files changed

+325
-63
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
namespace DigitalLearningSolutions.Data.Migrations
2+
{
3+
using FluentMigrator;
4+
5+
[Migration(202508261415, TransactionBehavior.None)]
6+
public class RemoveCustomAdminTitlesAddSupervisorNominatedSupervisor : Migration
7+
{
8+
public override void Up()
9+
{
10+
Execute.Sql(Properties.Resources.TD_5638_SnapshotData_UP);
11+
12+
Execute.Sql($@"
13+
-- 1. Drop old FK
14+
ALTER TABLE [dbo].[SelfAssessmentSupervisorRoles]
15+
DROP CONSTRAINT [FK_SelfAssessmentSupervisorRoles_SelfAssessmentID_SelfAssessments_ID];
16+
17+
18+
-- 2. Make column nullable
19+
ALTER TABLE [dbo].[SelfAssessmentSupervisorRoles]
20+
ALTER COLUMN SelfAssessmentID INT NULL;
21+
22+
23+
-- 3. Recreate FK (allows NULLs by default)
24+
ALTER TABLE [dbo].[SelfAssessmentSupervisorRoles]
25+
ADD CONSTRAINT [FK_SelfAssessmentSupervisorRoles_SelfAssessmentID_SelfAssessments_ID]
26+
FOREIGN KEY (SelfAssessmentID) REFERENCES SelfAssessments(ID);
27+
28+
29+
-- 4. Add two default roles
30+
INSERT INTO [dbo].[SelfAssessmentSupervisorRoles]
31+
([SelfAssessmentID],[RoleName],[SelfAssessmentReview],[ResultsReview]
32+
,[RoleDescription]
33+
,[AllowDelegateNomination],[AllowSupervisorRoleSelection])
34+
VALUES
35+
(NULL,'Supervisor',1,1
36+
,'This person may be the line manager, practice educator or educational supervisor at University.'
37+
,0,1),
38+
(NULL,'Nominated Supervisor',0,1
39+
,'Nominated Supervisors must be deemed competent to administer intravenous medication by their home organisation. Nominated Supervisors should be authorised to supervise and assess the practice of others by their line manager, who should consider their level of experience.'
40+
,1,0);
41+
42+
43+
-- 5. Update all CandidateAssessmentSupervisor records
44+
UPDATE cas
45+
SET cas.SelfAssessmentSupervisorRoleID =
46+
    CASE
47+
        WHEN sasr.RoleName = 'Educator/Manager' THEN sup.ID
48+
        WHEN sasr.RoleName = 'Assessor'         THEN nom.ID
49+
    END
50+
FROM CandidateAssessmentSupervisors cas
51+
INNER JOIN SelfAssessmentSupervisorRoles sasr
52+
    ON cas.SelfAssessmentSupervisorRoleID = sasr.ID
53+
LEFT JOIN SelfAssessmentSupervisorRoles sup
54+
    ON sup.RoleName = 'Supervisor'
55+
LEFT JOIN SelfAssessmentSupervisorRoles nom
56+
    ON nom.RoleName = 'Nominated Supervisor';
57+
58+
59+
-- 6. Remove all existing roles where SelfAssessmentID is not null
60+
DELETE FROM SelfAssessmentSupervisorRoles WHERE SelfAssessmentID IS NOT NULL;
61+
"
62+
);
63+
}
64+
65+
public override void Down()
66+
{
67+
// Intentionally empty. If things go wrong later, we will manually restore the snapshot
68+
}
69+
}
70+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
namespace DigitalLearningSolutions.Data.Migrations
2+
{
3+
using FluentMigrator;
4+
5+
[Migration(202508281600)]
6+
public class AlterGetCandidateAssessmentResultsByIdSP : Migration
7+
{
8+
public override void Up()
9+
{
10+
Execute.Sql(Properties.Resources.TD_5638_Alter_GetCandidateAssessmentResultsById_Up);
11+
}
12+
public override void Down()
13+
{
14+
Execute.Sql(Properties.Resources.TD_5638_Alter_GetCandidateAssessmentResultsById_DOWN);
15+
}
16+
}
17+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+

2+
3+
namespace DigitalLearningSolutions.Data.Migrations
4+
{
5+
using FluentMigrator;
6+
7+
[Migration(202508281630)]
8+
public class AlterGetAssessmentResultsByDelegateSP : Migration
9+
{
10+
public override void Up()
11+
{
12+
Execute.Sql(Properties.Resources.TD_5638_Alter_GetAssessmentResultsByDelegate_Up);
13+
}
14+
public override void Down()
15+
{
16+
Execute.Sql(Properties.Resources.TD_5638_Alter_GetAssessmentResultsByDelegate_DOWN);
17+
}
18+
}
19+
}

DigitalLearningSolutions.Data.Migrations/Properties/Resources.Designer.cs

Lines changed: 112 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DigitalLearningSolutions.Data.Migrations/Properties/Resources.resx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,4 +505,19 @@
505505
<data name="TD_5535_Alter_GetActivitiesForDelegateEnrolment_Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
506506
<value>..\Scripts\TD-5535-Alter_GetActivitiesForDelegateEnrolment_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
507507
</data>
508+
<data name="TD_5638_Alter_GetAssessmentResultsByDelegate_DOWN" type="System.Resources.ResXFileRef, System.Windows.Forms">
509+
<value>..\Scripts\TD-5638-Alter_GetAssessmentResultsByDelegate_DOWN.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
510+
</data>
511+
<data name="TD_5638_Alter_GetAssessmentResultsByDelegate_Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
512+
<value>..\Scripts\TD-5638-Alter_GetAssessmentResultsByDelegate_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
513+
</data>
514+
<data name="TD_5638_Alter_GetCandidateAssessmentResultsById_DOWN" type="System.Resources.ResXFileRef, System.Windows.Forms">
515+
<value>..\Scripts\TD-5638-Alter_GetCandidateAssessmentResultsById_DOWN.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
516+
</data>
517+
<data name="TD_5638_Alter_GetCandidateAssessmentResultsById_Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
518+
<value>..\Scripts\TD-5638-Alter_GetCandidateAssessmentResultsById_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
519+
</data>
520+
<data name="TD_5638_SnapshotData_UP" type="System.Resources.ResXFileRef, System.Windows.Forms">
521+
<value>..\Scripts\TD-5638-SnapshotData-UP.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
522+
</data>
508523
</root>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
DECLARE @dbName NVARCHAR(128) = DB_NAME()
2+
DECLARE @defaultPath NVARCHAR(500) = CONVERT(NVARCHAR(500), SERVERPROPERTY('InstanceDefaultDataPath'))
3+
DECLARE @snapshotTime NVARCHAR(12) = FORMAT(GETDATE(), 'yyyyMMddHHmm')
4+
5+
DECLARE @snapSql NVARCHAR(4000) = 'CREATE DATABASE ' + @dbName + '_' + @snapshotTime + ' ON
6+
( NAME = mbdbx101, FILENAME = ''' + @defaultPath + @dbName + '_' + @snapshotTime + '''),
7+
( NAME = mbdbx101files, FILENAME = ''' + @defaultPath + @dbName + '_filestream1_' + @snapshotTime + ''')
8+
AS SNAPSHOT OF ' + @dbName
9+
10+
EXEC sp_executesql @stmt = @SnapSql

0 commit comments

Comments
 (0)