Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ODS-6548] Remove clustered indexes from authorization views for SQL Server #1182

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

semalaiappan
Copy link
Contributor

No description provided.

DROP INDEX UX_EducationOrganizationIdToStudentUSI ON auth.EducationOrganizationIdToStudentUSI;
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStudentUSI'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use CREATE OR ALTER VIEW below instead -- and then remove this block.

DROP INDEX UX_EducationOrganizationIdToParentUSI ON auth.EducationOrganizationIdToParentUSI;
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToParentUSI'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CREATE OR ALTER VIEW is already in use below, so no need for this block.

GO

CREATE OR ALTER VIEW auth.EducationOrganizationIdToParentUSI AS
SELECT edOrgs.SourceEducationOrganizationId, spa.ParentUSI
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you've missed the COUNT_BIG part of the SQL statement on this one. I haven't built it locally, but from migration scripts in the folder, it seems like the most recent version is the "1350" file, which has it.

Please modify this SQL as follows:

CREATE OR ALTER VIEW auth.EducationOrganizationIdToParentUSI 
    SELECT  edOrgs.SourceEducationOrganizationId, spa.ParentUSI, COUNT_BIG(*) AS Ignored
    FROM    auth.EducationOrganizationIdToEducationOrganizationId edOrgs
            INNER JOIN edfi.StudentSchoolAssociation ssa 
                ON edOrgs.TargetEducationOrganizationId = ssa.SchoolId
            INNER JOIN edfi.StudentParentAssociation spa 
                ON ssa.StudentUSI = spa.StudentUSI
    GROUP BY edOrgs.SourceEducationOrganizationId, spa.ParentUSI

GROUP BY edOrgs.SourceEducationOrganizationId, spa.ParentUSI
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStaffUSI'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use CREATE OR ALTER VIEW below instead -- and then remove this block.

ON edOrgs.TargetEducationOrganizationId = seo_empl.EducationOrganizationId
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStudentUSIThroughResponsibility'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use CREATE OR ALTER VIEW below instead -- and then remove this block.

DROP VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility;
GO

CREATE VIEW auth.EducationOrganizationIdToStudentUSIThroughResponsibility AS
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use CREATE OR ALTER VIEW instead.

GROUP BY edOrgs.SourceEducationOrganizationId, spa.ContactUSI
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStaffUSI'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use CREATE OR ALTER VIEW below instead -- and then remove this block.

ON edOrgs.TargetEducationOrganizationId = seo_empl.EducationOrganizationId
GO

IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'auth.EducationOrganizationIdToStudentUSIThroughResponsibility'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use CREATE OR ALTER VIEW below instead -- and then remove this block.

INNER JOIN edfi.StudentEducationOrganizationResponsibilityAssociation seora
ON edOrgs.TargetEducationOrganizationId = seora.EducationOrganizationId
GROUP BY edOrgs.SourceEducationOrganizationId, seora.StudentUSI
GO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a blank line at the end of the file.

INNER JOIN edfi.StudentEducationOrganizationResponsibilityAssociation seora
ON edOrgs.TargetEducationOrganizationId = seora.EducationOrganizationId
GROUP BY edOrgs.SourceEducationOrganizationId, seora.StudentUSI
GO
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a blank line at the end of the file.

@semalaiappan
Copy link
Contributor Author

@gmcelhanon @mjaksn Ready for review again . Thank you !

@gmcelhanon gmcelhanon merged commit c59facc into main Nov 7, 2024
16 checks passed
@gmcelhanon gmcelhanon deleted the ODS-6548 branch November 7, 2024 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants