Created
October 28, 2015 16:08
-
-
Save timgaunt/0a1bfde6fabb8aab4b14 to your computer and use it in GitHub Desktop.
Create an umbraco database -just replace "DATABASENAME" with your database name
This file contains hidden or 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
USE Master | |
GO | |
CREATE DATABASE DATABASENAMECMS | |
GO | |
DECLARE @DatabaseName nvarchar(255), @Username nvarchar(255), @Password nvarchar(255), @AddToASPNet bit, @IsUmbracoInstall bit | |
SET @DatabaseName = 'DATABASENAMECMS' -- NOTE this must also match the CREATE value above and below the "Creating Users" script | |
SET @Username = 'DATABASENAMEUser' | |
SET @Password = '' | |
SET @AddToASPNet = 0 | |
SET @IsUmbracoInstall = 1 | |
/*-------------------------------------------------------------------------------------*/ | |
PRINT 'Creating Users' | |
/*-------------------------------------------------------------------------------------*/ | |
-- Setup the main logon and user -used for the website | |
IF NOT EXISTS (select * from master.dbo.syslogins where loginname = @Username) | |
EXEC sp_addlogin @Username, @Password, @DatabaseName, 'us_english' | |
USE DATABASENAMECMS | |
IF NOT EXISTS (select * from dbo.sysusers where name = @Username) | |
EXEC sp_grantdbaccess @Username, @Username | |
/*-------------------------------------------------------------------------------------*/ | |
-- If this is an Umbraco install then we'll need to add them to dbowner | |
IF @IsUmbracoInstall = '1' | |
BEGIN | |
PRINT 'Setting up Umbraco permissions' | |
EXEC sp_addrolemember N'db_owner', @Username | |
END | |
/*-------------------------------------------------------------------------------------*/ | |
-- If this user needs to have access to the ASPNet login database then add them | |
IF @AddToASPNet = '1' | |
BEGIN | |
/*------------------------------------------------------------------------------------- | |
NOTE: If you don't have an ASPNet database, you will need to script it | |
Run the following command from the Visual Studio Command Prompt: | |
aspnet_regsql -S ##SERVER NAME/IP ADDRESS## -E -d ASPNet -A all | |
The role IIS_User should already exist, if not then you will need to assign the relevant | |
object permissions to the role (See accompanying SQL file TSDAuditTrail.sql) | |
-------------------------------------------------------------------------------------*/ | |
PRINT 'Setting up ASPNet permissions' | |
USE ASPNet | |
IF NOT EXISTS (select * from dbo.sysusers where name = @Username) | |
EXEC sp_grantdbaccess @Username, @Username | |
IF NOT EXISTS (select * from dbo.sysusers where name = N'IIS_User') | |
EXEC sp_addrole N'IIS_User' | |
EXEC sp_addrolemember N'IIS_User', @Username | |
END | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment