Skip to content

Commit

Permalink
[ODS-6569] Update 4.0 artifacts to include all 7.3 sql script updates…
Browse files Browse the repository at this point in the history
… from MetaEd (#1187)
  • Loading branch information
semalaiappan authored Nov 22, 2024
1 parent f5f76ac commit 74ebd05
Show file tree
Hide file tree
Showing 13 changed files with 2,961 additions and 1,854 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
-- SPDX-License-Identifier: Apache-2.0
-- Licensed to the Ed-Fi Alliance under one or more agreements.
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
-- See the LICENSE and NOTICES files in the project root for more information.

CREATE TRIGGER [edfi].[edfi_AssessmentSection_TR_Assessment_Update]
ON [edfi].[AssessmentSection]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;

-- Check if any volatile foreign key values have changed
IF UPDATE(LocalCourseCode)
OR UPDATE(SchoolId)
OR UPDATE(SchoolYear)
OR UPDATE(SectionIdentifier)
OR UPDATE(SessionName)
BEGIN
-- Update the LastModifiedDate in the root table to the current UTC time
UPDATE rt
SET rt.LastModifiedDate = GETUTCDATE()
FROM [edfi].[Assessment] rt
INNER JOIN inserted i
ON rt.AssessmentIdentifier = i.AssessmentIdentifier
AND rt.Namespace = i.Namespace;
END
END;
GO

CREATE TRIGGER [edfi].[edfi_BellScheduleClassPeriod_TR_BellSchedule_Update]
ON [edfi].[BellScheduleClassPeriod]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;

-- Check if any volatile foreign key values have changed
IF UPDATE(ClassPeriodName)
OR UPDATE(SchoolId)
BEGIN
-- Update the LastModifiedDate in the root table to the current UTC time
UPDATE rt
SET rt.LastModifiedDate = GETUTCDATE()
FROM [edfi].[BellSchedule] rt
INNER JOIN inserted i
ON rt.BellScheduleName = i.BellScheduleName
AND rt.SchoolId = i.SchoolId;
END
END;
GO

CREATE TRIGGER [edfi].[edfi_ReportCardGrade_TR_ReportCard_Update]
ON [edfi].[ReportCardGrade]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;

-- Check if any volatile foreign key values have changed
IF UPDATE(BeginDate)
OR UPDATE(GradeTypeDescriptorId)
OR UPDATE(GradingPeriodDescriptorId)
OR UPDATE(GradingPeriodSequence)
OR UPDATE(GradingPeriodSchoolYear)
OR UPDATE(LocalCourseCode)
OR UPDATE(SchoolId)
OR UPDATE(SchoolYear)
OR UPDATE(SectionIdentifier)
OR UPDATE(SessionName)
OR UPDATE(StudentUSI)
BEGIN
-- Update the LastModifiedDate in the root table to the current UTC time
UPDATE rt
SET rt.LastModifiedDate = GETUTCDATE()
FROM [edfi].[ReportCard] rt
INNER JOIN inserted i
ON rt.EducationOrganizationId = i.EducationOrganizationId
AND rt.GradingPeriodDescriptorId = i.GradingPeriodDescriptorId
AND rt.GradingPeriodSequence = i.GradingPeriodSequence
AND rt.GradingPeriodSchoolId = i.GradingPeriodSchoolId
AND rt.GradingPeriodSchoolYear = i.GradingPeriodSchoolYear
AND rt.StudentUSI = i.StudentUSI;
END
END;
GO

CREATE TRIGGER [edfi].[edfi_SectionClassPeriod_TR_Section_Update]
ON [edfi].[SectionClassPeriod]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;

-- Check if any volatile foreign key values have changed
IF UPDATE(ClassPeriodName)
OR UPDATE(SchoolId)
BEGIN
-- Update the LastModifiedDate in the root table to the current UTC time
UPDATE rt
SET rt.LastModifiedDate = GETUTCDATE()
FROM [edfi].[Section] rt
INNER JOIN inserted i
ON rt.LocalCourseCode = i.LocalCourseCode
AND rt.SchoolId = i.SchoolId
AND rt.SchoolYear = i.SchoolYear
AND rt.SectionIdentifier = i.SectionIdentifier
AND rt.SessionName = i.SessionName;
END
END;
GO

CREATE TRIGGER [edfi].[edfi_StudentCohortAssociationSection_TR_StudentCohortAssociation_Update]
ON [edfi].[StudentCohortAssociationSection]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;

-- Check if any volatile foreign key values have changed
IF UPDATE(LocalCourseCode)
OR UPDATE(SchoolId)
OR UPDATE(SchoolYear)
OR UPDATE(SectionIdentifier)
OR UPDATE(SessionName)
BEGIN
-- Update the LastModifiedDate in the root table to the current UTC time
UPDATE rt
SET rt.LastModifiedDate = GETUTCDATE()
FROM [edfi].[StudentCohortAssociation] rt
INNER JOIN inserted i
ON rt.BeginDate = i.BeginDate
AND rt.CohortIdentifier = i.CohortIdentifier
AND rt.EducationOrganizationId = i.EducationOrganizationId
AND rt.StudentUSI = i.StudentUSI;
END
END;
GO

CREATE TRIGGER [edfi].[edfi_StudentCompetencyObjectiveStudentSectionAssociation_TR_StudentCompetencyObjective_Update]
ON [edfi].[StudentCompetencyObjectiveStudentSectionAssociation]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;

-- Check if any volatile foreign key values have changed
IF UPDATE(BeginDate)
OR UPDATE(LocalCourseCode)
OR UPDATE(SchoolId)
OR UPDATE(SchoolYear)
OR UPDATE(SectionIdentifier)
OR UPDATE(SessionName)
OR UPDATE(StudentUSI)
BEGIN
-- Update the LastModifiedDate in the root table to the current UTC time
UPDATE rt
SET rt.LastModifiedDate = GETUTCDATE()
FROM [edfi].[StudentCompetencyObjective] rt
INNER JOIN inserted i
ON rt.GradingPeriodDescriptorId = i.GradingPeriodDescriptorId
AND rt.GradingPeriodSequence = i.GradingPeriodSequence
AND rt.GradingPeriodSchoolId = i.GradingPeriodSchoolId
AND rt.GradingPeriodSchoolYear = i.GradingPeriodSchoolYear
AND rt.ObjectiveEducationOrganizationId = i.ObjectiveEducationOrganizationId
AND rt.Objective = i.Objective
AND rt.ObjectiveGradeLevelDescriptorId = i.ObjectiveGradeLevelDescriptorId
AND rt.StudentUSI = i.StudentUSI;
END
END;
GO

CREATE TRIGGER [edfi].[edfi_StudentLearningObjectiveStudentSectionAssociation_TR_StudentLearningObjective_Update]
ON [edfi].[StudentLearningObjectiveStudentSectionAssociation]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;

-- Check if any volatile foreign key values have changed
IF UPDATE(BeginDate)
OR UPDATE(LocalCourseCode)
OR UPDATE(SchoolId)
OR UPDATE(SchoolYear)
OR UPDATE(SectionIdentifier)
OR UPDATE(SessionName)
OR UPDATE(StudentUSI)
BEGIN
-- Update the LastModifiedDate in the root table to the current UTC time
UPDATE rt
SET rt.LastModifiedDate = GETUTCDATE()
FROM [edfi].[StudentLearningObjective] rt
INNER JOIN inserted i
ON rt.GradingPeriodDescriptorId = i.GradingPeriodDescriptorId
AND rt.GradingPeriodSequence = i.GradingPeriodSequence
AND rt.GradingPeriodSchoolId = i.GradingPeriodSchoolId
AND rt.GradingPeriodSchoolYear = i.GradingPeriodSchoolYear
AND rt.LearningObjectiveId = i.LearningObjectiveId
AND rt.Namespace = i.Namespace
AND rt.StudentUSI = i.StudentUSI;
END
END;
GO

CREATE TRIGGER [edfi].[edfi_StudentSectionAttendanceEventClassPeriod_TR_StudentSectionAttendanceEvent_Update]
ON [edfi].[StudentSectionAttendanceEventClassPeriod]
AFTER UPDATE
AS
BEGIN
SET NOCOUNT ON;

-- Check if any volatile foreign key values have changed
IF UPDATE(ClassPeriodName)
OR UPDATE(SchoolId)
BEGIN
-- Update the LastModifiedDate in the root table to the current UTC time
UPDATE rt
SET rt.LastModifiedDate = GETUTCDATE()
FROM [edfi].[StudentSectionAttendanceEvent] rt
INNER JOIN inserted i
ON rt.AttendanceEventCategoryDescriptorId = i.AttendanceEventCategoryDescriptorId
AND rt.EventDate = i.EventDate
AND rt.LocalCourseCode = i.LocalCourseCode
AND rt.SchoolId = i.SchoolId
AND rt.SchoolYear = i.SchoolYear
AND rt.SectionIdentifier = i.SectionIdentifier
AND rt.SessionName = i.SessionName
AND rt.StudentUSI = i.StudentUSI;
END
END;
GO

Loading

0 comments on commit 74ebd05

Please sign in to comment.