-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/54223 adminlogonevent school id col (#2331)
* add migration * add local strategy * Add index to fk col * Update local strategy tests * Mod dfe strategy * Remove lint * admin logon event tests * Update sign_in_steps.rb Co-authored-by: Guy Harwood <[email protected]> Co-authored-by: Mohsen Qureshi <[email protected]> Co-authored-by: Mohsen Qureshi <[email protected]>
- Loading branch information
1 parent
816bf19
commit 61a658b
Showing
8 changed files
with
95 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
db/migrations/schema-objects/20221027152055.do.add-school-id-to-adminlogonevent.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
-- Add new school_id column | ||
IF NOT EXISTS( | ||
SELECT * | ||
FROM sys.columns | ||
WHERE object_ID = object_id('mtc_admin.adminLogonEvent') | ||
AND col_name(object_ID, column_Id) = 'school_id') | ||
BEGIN | ||
ALTER TABLE [mtc_admin].[adminLogonEvent] | ||
ADD [school_id] INT; | ||
END | ||
|
||
go | ||
|
||
-- make it a foreign key | ||
IF NOT EXISTS(SELECT * | ||
FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE | ||
WHERE CONSTRAINT_COLUMN_USAGE.TABLE_SCHEMA = 'mtc_admin' | ||
AND CONSTRAINT_COLUMN_USAGE.TABLE_NAME = 'adminLogonEvent' | ||
AND CONSTRAINT_COLUMN_USAGE.COLUMN_NAME = 'school_id' | ||
AND CONSTRAINT_NAME = 'FK_adminLogonEvent_school_id') | ||
BEGIN | ||
ALTER TABLE [mtc_admin].[adminLogonEvent] | ||
ADD CONSTRAINT [FK_adminLogonEvent_school_id] | ||
FOREIGN KEY (school_id) REFERENCES [mtc_admin].[school] (id); | ||
END | ||
|
||
-- add an index | ||
DROP INDEX IF EXISTS [mtc_admin].[adminLogonEvent].[IX_adminLogonEvent_school_id]; | ||
CREATE INDEX IX_adminLogonEvent_school_id ON mtc_admin.adminLogonEvent([school_id]); |
19 changes: 19 additions & 0 deletions
19
db/migrations/schema-objects/20221027152055.undo.add-school-id-to-adminlogonevent.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- drop index | ||
DROP INDEX IF EXISTS [mtc_admin].[adminLogonEvent].[IX_adminLogonEvent_school_id]; | ||
|
||
-- drop foreign key | ||
IF EXISTS(SELECT * | ||
FROM INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE | ||
WHERE CONSTRAINT_COLUMN_USAGE.TABLE_SCHEMA = 'mtc_admin' | ||
AND CONSTRAINT_COLUMN_USAGE.TABLE_NAME = 'adminLogonEvent' | ||
AND CONSTRAINT_COLUMN_USAGE.COLUMN_NAME = 'school_id' | ||
AND CONSTRAINT_NAME = 'FK_adminLogonEvent_school_id') | ||
BEGIN | ||
ALTER TABLE [mtc_admin].[adminLogonEvent] | ||
DROP CONSTRAINT [FK_adminLogonEvent_school_id]; | ||
END | ||
|
||
|
||
|
||
-- drop column | ||
ALTER TABLE [mtc_admin].[adminLogonEvent] DROP COLUMN IF EXISTS [school_id]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters