Skip to content

Commit

Permalink
[ODS-6520] Bring in first set of DS 5.2 updates (#1155)
Browse files Browse the repository at this point in the history
  • Loading branch information
semalaiappan authored Oct 11, 2024
1 parent d133ce6 commit 8a61064
Show file tree
Hide file tree
Showing 83 changed files with 3,284 additions and 7,601 deletions.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -4015,6 +4015,14 @@ REFERENCES [edfi].[Descriptor] ([DescriptorId])
ON DELETE CASCADE
GO

ALTER TABLE [edfi].[RestraintEvent] WITH CHECK ADD CONSTRAINT [FK_RestraintEvent_DisciplineIncident] FOREIGN KEY ([IncidentIdentifier], [SchoolId])
REFERENCES [edfi].[DisciplineIncident] ([IncidentIdentifier], [SchoolId])
GO

CREATE NONCLUSTERED INDEX [FK_RestraintEvent_DisciplineIncident]
ON [edfi].[RestraintEvent] ([IncidentIdentifier] ASC, [SchoolId] ASC)
GO

ALTER TABLE [edfi].[RestraintEvent] WITH CHECK ADD CONSTRAINT [FK_RestraintEvent_EducationalEnvironmentDescriptor] FOREIGN KEY ([EducationalEnvironmentDescriptorId])
REFERENCES [edfi].[EducationalEnvironmentDescriptor] ([EducationalEnvironmentDescriptorId])
GO
Expand Down Expand Up @@ -6605,11 +6613,6 @@ REFERENCES [edfi].[Student] ([StudentUSI])
ON DELETE CASCADE
GO

ALTER TABLE [edfi].[StudentParticipationCodeDescriptor] WITH CHECK ADD CONSTRAINT [FK_StudentParticipationCodeDescriptor_Descriptor] FOREIGN KEY ([StudentParticipationCodeDescriptorId])
REFERENCES [edfi].[Descriptor] ([DescriptorId])
ON DELETE CASCADE
GO

ALTER TABLE [edfi].[StudentPersonalIdentificationDocument] WITH CHECK ADD CONSTRAINT [FK_StudentPersonalIdentificationDocument_CountryDescriptor] FOREIGN KEY ([IssuerCountryDescriptorId])
REFERENCES [edfi].[CountryDescriptor] ([CountryDescriptorId])
GO
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@
-- 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.

/* Generated with SSMS using:
------------------------------------------------
SELECT 'CREATE SEQUENCE [' + c.TABLE_SCHEMA + '].[' + c.TABLE_NAME + '_AggSeq] START WITH -2147483648 INCREMENT BY 1; ALTER TABLE [' + c.TABLE_SCHEMA + '].[' + c.TABLE_NAME + '] ADD AggregateId int NOT NULL DEFAULT NEXT VALUE FOR [' + c.TABLE_SCHEMA + '].[' + c.TABLE_NAME + '_AggSeq]; CREATE INDEX [IX_' + c.TABLE_NAME + '_AggregateId] ON [' + c.TABLE_SCHEMA + '].[' + c.TABLE_NAME + '] (AggregateId);' AS SqlServer
FROM INFORMATION_SCHEMA.COLUMNS c
WHERE c.COLUMN_NAME = 'Id' and c.TABLE_SCHEMA = @schema
ORDER BY c.TABLE_SCHEMA, c.TABLE_NAME
------------------------------------------------
*/

CREATE SEQUENCE [edfi].[AcademicWeek_AggSeq] START WITH -2147483648 INCREMENT BY 1;
ALTER TABLE [edfi].[AcademicWeek] ADD AggregateId int NOT NULL DEFAULT NEXT VALUE FOR [edfi].[AcademicWeek_AggSeq];
CREATE INDEX [IX_AcademicWeek_AggregateId] ON [edfi].[AcademicWeek] (AggregateId);
Expand Down Expand Up @@ -475,3 +466,4 @@ CREATE INDEX [IX_SurveySectionResponseEducationOrganizationTargetAssociation_Agg
CREATE SEQUENCE [edfi].[SurveySectionResponseStaffTargetAssociation_AggSeq] START WITH -2147483648 INCREMENT BY 1;
ALTER TABLE [edfi].[SurveySectionResponseStaffTargetAssociation] ADD AggregateId int NOT NULL DEFAULT NEXT VALUE FOR [edfi].[SurveySectionResponseStaffTargetAssociation_AggSeq];
CREATE INDEX [IX_SurveySectionResponseStaffTargetAssociation_AggregateId] ON [edfi].[SurveySectionResponseStaffTargetAssociation] (AggregateId);

Original file line number Diff line number Diff line change
Expand Up @@ -5996,27 +5996,6 @@ ALTER TABLE [edfi].[StudentInterventionAttendanceEvent] ENABLE TRIGGER [edfi_Stu
GO


DROP TRIGGER IF EXISTS [edfi].[edfi_StudentParticipationCodeDescriptor_TR_DeleteTracking]
GO

CREATE TRIGGER [edfi].[edfi_StudentParticipationCodeDescriptor_TR_DeleteTracking] ON [edfi].[StudentParticipationCodeDescriptor] AFTER DELETE AS
BEGIN
IF @@rowcount = 0
RETURN

SET NOCOUNT ON

INSERT INTO [tracked_changes_edfi].[Descriptor](OldDescriptorId, OldCodeValue, OldNamespace, Id, Discriminator, ChangeVersion)
SELECT d.StudentParticipationCodeDescriptorId, b.CodeValue, b.Namespace, b.Id, 'edfi.StudentParticipationCodeDescriptor', (NEXT VALUE FOR [changes].[ChangeVersionSequence])
FROM deleted d
INNER JOIN edfi.Descriptor b ON d.StudentParticipationCodeDescriptorId = b.DescriptorId
END
GO

ALTER TABLE [edfi].[StudentParticipationCodeDescriptor] ENABLE TRIGGER [edfi_StudentParticipationCodeDescriptor_TR_DeleteTracking]
GO


DROP TRIGGER IF EXISTS [edfi].[edfi_StudentProgramAttendanceEvent_TR_DeleteTracking]
GO

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
-- 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_CourseTranscriptSection_TR_CourseTranscript_Update]
ON [edfi].[CourseTranscriptSection]
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].[CourseTranscript] rt
INNER JOIN inserted i
ON rt.CourseAttemptResultDescriptorId = i.CourseAttemptResultDescriptorId
AND rt.CourseCode = i.CourseCode
AND rt.CourseEducationOrganizationId = i.CourseEducationOrganizationId
AND rt.EducationOrganizationId = i.EducationOrganizationId
AND rt.SchoolYear = i.SchoolYear
AND rt.StudentUSI = i.StudentUSI
AND rt.TermDescriptorId = i.TermDescriptorId;
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(GradingPeriodName)
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.GradingPeriodName = i.GradingPeriodName
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.GradingPeriodName = i.GradingPeriodName
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_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 8a61064

Please sign in to comment.