Skip to content

Commit

Permalink
Fix sql for bacpac to local sql
Browse files Browse the repository at this point in the history
  • Loading branch information
skaue committed Aug 10, 2018
1 parent e651dd5 commit 685d90b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 2 additions & 0 deletions functions/import-d365bacpac.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ function Import-D365Bacpac {

}

$commandText = $commandText.Replace('@axdatabasename', $NewDatabaseName)

$commandText = $commandText.Replace('@axdeployextuser', $AxDeployExtUserPwd)

$commandText = $commandText.Replace('@axdbadmin', $AxDbAdminPwd)
Expand Down
13 changes: 11 additions & 2 deletions internal/sql/set-bacpacvaluessql.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
DROP USER IF EXISTS [axretailruntimeuser]
DROP USER IF EXISTS [axretaildatasyncuser]
DROP USER IF EXISTS [axmrruntimeuser]
DROP USER IF EXISTS [axdeployuser]
DROP USER IF EXISTS [axdbadmin]
DROP USER IF EXISTS [axdeployextuser]
DROP USER IF EXISTS [NT AUTHORITY\NETWORK SERVICE]

CREATE USER axdeployuser FROM LOGIN axdeployuser
EXEC sp_addrolemember 'db_owner', 'axdeployuser'

Expand All @@ -15,7 +23,7 @@ CREATE USER axretailruntimeuser FROM LOGIN axretailruntimeuser
EXEC sp_addrolemember 'UsersRole', 'axretailruntimeuser'
EXEC sp_addrolemember 'ReportUsersRole', 'axretailruntimeuser'

CREATE USER axdeployextuser WITH PASSWORD = '@axdeployextuser'
CREATE USER axdeployextuser FROM LOGIN axdeployextuser
EXEC sp_addrolemember 'DeployExtensibilityRole', 'axdeployextuser'

CREATE USER [NT AUTHORITY\NETWORK SERVICE] FROM LOGIN [NT AUTHORITY\NETWORK SERVICE]
Expand All @@ -29,7 +37,8 @@ SET T1.storageproviderid = 0
FROM docuvalue T1
WHERE T1.storageproviderid = 1 --Azure storage

ALTER DATABASE [<your AX database name>] SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 6 DAYS, AUTO_CLEANUP = ON)
IF(0=(SELECT 1 FROM SYS.CHANGE_TRACKING_DATABASES WHERE DATABASE_ID = DB_ID('[@axdatabasename]')))
ALTER DATABASE [@axdatabasename] SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 6 DAYS, AUTO_CLEANUP = ON)
;--GO
DROP PROCEDURE IF EXISTS SP_ConfigureTablesForChangeTracking
DROP PROCEDURE IF EXISTS SP_ConfigureTablesForChangeTracking_V2
Expand Down

0 comments on commit 685d90b

Please sign in to comment.