mirror of
https://github.com/bitwarden/server.git
synced 2024-12-01 13:43:23 +01:00
f7bc5dfb2e
* Remove OrganizationUser.AccessAll * Final database migrations
46 lines
1.5 KiB
Transact-SQL
46 lines
1.5 KiB
Transact-SQL
-- Finalise removal of OrganizationUser.AccessAll column
|
|
-- Drop the column
|
|
|
|
/****************************************************************
|
|
*
|
|
* WARNING: Index Rebuild on OrganizationUser Table!
|
|
* Ensure [IX_OrganizationUser_UserIdOrganizationIdStatus] impact is done after-hours
|
|
* or scale DB instance up to handle increased load during update.
|
|
*
|
|
***************************************************************/
|
|
|
|
-- Create the new index (without the column) before we drop the old index
|
|
PRINT N'Creating index IX_OrganizationUser_UserIdOrganizationIdStatusV2...';
|
|
CREATE NONCLUSTERED INDEX [IX_OrganizationUser_UserIdOrganizationIdStatusV2]
|
|
ON [dbo].[OrganizationUser]([UserId] ASC, [OrganizationId] ASC, [Status] ASC);
|
|
|
|
-- Drop the old index that refers to the column
|
|
PRINT N'Dropping index IX_OrganizationUser_UserIdOrganizationIdStatus...';
|
|
DROP INDEX IF EXISTS [IX_OrganizationUser_UserIdOrganizationIdStatus]
|
|
ON [dbo].[OrganizationUser];
|
|
|
|
-- Drop default constraint
|
|
IF OBJECT_ID('[dbo].[DF_OrganizationUser_AccessAll]', 'D') IS NOT NULL
|
|
BEGIN
|
|
ALTER TABLE [dbo].[OrganizationUser]
|
|
DROP CONSTRAINT [DF_OrganizationUser_AccessAll];
|
|
END
|
|
GO
|
|
|
|
-- Drop the column
|
|
IF COL_LENGTH('[dbo].[OrganizationUser]', 'AccessAll') IS NOT NULL
|
|
BEGIN
|
|
ALTER TABLE
|
|
[dbo].[OrganizationUser]
|
|
DROP COLUMN
|
|
[AccessAll]
|
|
END
|
|
GO
|
|
|
|
-- Refresh views
|
|
IF OBJECT_ID('[dbo].[OrganizationUserView]') IS NOT NULL
|
|
BEGIN
|
|
EXECUTE sp_refreshsqlmodule N'[dbo].[OrganizationUserView]';
|
|
END
|
|
GO
|