EnVisageOnline/Main/Database/Scripts/20141017/02_modify_Security_table.sql

58 lines
1.3 KiB
Transact-SQL

USE [EnVisage]
begin transaction
create table tmp_Security(
[PrincipalId] [uniqueidentifier] NOT NULL,
[Read] [int] NOT NULL,
[Write] [int] NOT NULL,
[SecurityObject] [nvarchar](50) NOT NULL
)
insert into tmp_Security
select * from Security
ALTER TABLE [dbo].[Security] DROP CONSTRAINT [DF_Security_Write]
ALTER TABLE [dbo].[Security] DROP CONSTRAINT [DF_Security_Read]
/****** Object: Table [dbo].[Security] Script Date: 10/17/2014 4:45:24 PM ******/
DROP TABLE [dbo].[Security]
/****** Object: Table [dbo].[Security] Script Date: 10/17/2014 4:45:24 PM ******/
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE TABLE [dbo].[Security](
[PrincipalId] [uniqueidentifier] NOT NULL,
[Read] [int] NOT NULL,
[Write] [int] NOT NULL,
[SecurityObject] [nvarchar](50) NOT NULL,
CONSTRAINT [PK_Security] PRIMARY KEY CLUSTERED
(
[PrincipalId] ASC,
[SecurityObject] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
insert into Security
select * from tmp_Security
drop table tmp_Security
commit
ALTER TABLE [dbo].[Security] ADD CONSTRAINT [DF_Security_Read] DEFAULT ((0)) FOR [Read]
ALTER TABLE [dbo].[Security] ADD CONSTRAINT [DF_Security_Write] DEFAULT ((0)) FOR [Write]