text: ﻿/****** Object:  Table [dbo].[Users]    Script Date: 6/11/2015 9:44:33 AM ******/
  SET ANSI_NULLS ON
  GO
  
  SET QUOTED_IDENTIFIER ON
  GO
  
  CREATE TABLE [dbo].[Roles](
  	[Id] [int] IDENTITY(1,1) NOT NULL,
  	[Name] [nvarchar](255) NOT NULL,
  	CreatedBy int not null,
  	CreatedDateTime datetime2 not null,
  	[IsDeleted] [bit] NOT NULL DEFAULT(0)
   CONSTRAINT [PK_Roles] PRIMARY KEY CLUSTERED 
  (
  	[Id] ASC
  )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  ) ON [PRIMARY]
  
  GO
  
  CREATE TABLE [dbo].[UserRoles](
  	[Id] [int] IDENTITY(1,1) NOT NULL,
  	[UserId] [int] NOT NULL,
  	[RoleId] [int] NOT NULL,
  	[IsDeleted] [bit] NOT NULL DEFAULT(0)
   CONSTRAINT [PK_UserRoles] PRIMARY KEY CLUSTERED 
  (
  	[Id] ASC
  )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
  ) ON [PRIMARY]
  
  GO
  
  ALTER TABLE [dbo].[UserRoles]  WITH CHECK ADD  CONSTRAINT [FK_UserRoles_Roles] FOREIGN KEY([RoleId])
  REFERENCES [dbo].[Roles] ([Id])
  GO
  
  ALTER TABLE [dbo].[UserRoles] CHECK CONSTRAINT [FK_UserRoles_Roles]
  GO
  
  ALTER TABLE [dbo].[UserRoles]  WITH CHECK ADD  CONSTRAINT [FK_UserRoles_Users] FOREIGN KEY([UserId])
  REFERENCES [dbo].[Users] ([Id])
  GO
  
  ALTER TABLE [dbo].[UserRoles] CHECK CONSTRAINT [FK_UserRoles_Users]
  GO
  
  INSERT INTO [dbo].[Roles]
             ([Name]
             ,[IsDeleted],
  		   CreatedBy,
  		   CreatedDateTime)
       VALUES
             ('Administrator'
             ,0
  		   ,0
  		   ,SYSDATETIME())
  GO
  
  ALTER TABLE [dbo].[Users]
  ADD FirstName [nvarchar](255) NOT NULL DEFAULT('')
  
  ALTER TABLE [dbo].[Users]
  ADD LastName [nvarchar](255) NOT NULL DEFAULT('')
  
  ALTER TABLE [dbo].[Users]
  ADD Email [nvarchar](255) NOT NULL DEFAULT('')
  
  GO