Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@


namespace DigitalLearningSolutions.Data.Migrations
{
using FluentMigrator;

[Migration(202504241045)]
public class Alter_ReorderFrameworkCompetency : Migration
{
public override void Up()
{
Execute.Sql(Properties.Resources.TD_5447_Alter_ReorderFrameworkCompetency_Up);
}
public override void Down()
{
Execute.Sql(Properties.Resources.TD_5447_Alter_ReorderFrameworkCompetency_Down);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
namespace DigitalLearningSolutions.Data.Migrations
{
using FluentMigrator;
[Migration(202504241115)]
public class UpdateFrameworkCompetenciesOrdering : ForwardOnlyMigration
{
public override void Up()
{
Execute.Sql(@"WITH Ranked AS (
    SELECT ID,
            ROW_NUMBER() OVER (PARTITION BY FrameworkID ORDER BY SysStartTime) AS NewOrder
    FROM FrameworkCompetencies
Where FrameworkCompetencyGroupID is null
)
UPDATE fc
SET fc.Ordering = r.NewOrder
FROM FrameworkCompetencies fc
JOIN Ranked r ON fc.ID = r.ID;");
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -475,4 +475,10 @@
<data name="TD_5412_Alter_SendExpiredTBCReminders_Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Scripts\TD-5412-Alter_SendExpiredTBCReminders_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
</data>
<data name="TD_5447_Alter_ReorderFrameworkCompetency_Down" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Scripts\TD-5447-Alter_ReorderFrameworkCompetency_Down.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
</data>
<data name="TD_5447_Alter_ReorderFrameworkCompetency_Up" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Scripts\TD-5447-Alter_ReorderFrameworkCompetency_Up.sql;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-16</value>
</data>
</root>
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,11 @@ public int InsertFrameworkCompetency(
var numberOfAffectedRows = connection.Execute(
@"INSERT INTO FrameworkCompetencies ([CompetencyID], FrameworkCompetencyGroupID, UpdatedByAdminID, Ordering, FrameworkID)
VALUES (@competencyId, @frameworkCompetencyGroupID, @adminId, COALESCE
((SELECT MAX(Ordering) AS OrderNum
FROM [FrameworkCompetencies]
WHERE ([FrameworkCompetencyGroupID] = @frameworkCompetencyGroupID)), 0)+1, @frameworkId)",
((SELECT MAX(Ordering) AS OrderNum
FROM [FrameworkCompetencies]
WHERE ((@frameworkCompetencyGroupID IS NULL AND FrameworkCompetencyGroupID IS NULL) OR
(@frameworkCompetencyGroupID IS NOT NULL AND FrameworkCompetencyGroupID = @frameworkCompetencyGroupID)) AND
FrameworkID = @frameworkId ), 0)+1, @frameworkId)",
new { competencyId, frameworkCompetencyGroupID, adminId, frameworkId }
);
if (numberOfAffectedRows < 1)
Expand All @@ -707,7 +709,7 @@ FROM [FrameworkCompetencies]
new { competencyId, frameworkCompetencyGroupID }
);
}
if(addDefaultQuestions)
if (addDefaultQuestions)
{
AddDefaultQuestionsToCompetency(competencyId, frameworkId);
}
Expand Down
Loading