Skip to content

Commit

Permalink
TPDMX-241/TPDMDEV-524 - PowerShell script to install views to SQL Ser…
Browse files Browse the repository at this point in the history
…ver DB (#40)

Adding script to create Analytics schema
  • Loading branch information
stevenarnold-ed-fi authored Jul 29, 2021
1 parent f9d73b5 commit ceb07eb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Starter Kit Support/Analytics Views/Schema-Analytics-Create.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- SPDX-License-Identifier: Apache-2.0
-- Licensed to the Ed-Fi Alliance under one or more agreements.
-- The Ed-Fi Alliance licenses this file to you under the Apache License, Version 2.0.
-- See the LICENSE and NOTICES files in the project root for more information.


IF NOT EXISTS (SELECT 1 FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = 'analytics')
BEGIN
EXEC sp_executesql N'CREATE SCHEMA [analytics]';
END
25 changes: 25 additions & 0 deletions Starter Kit Support/Analytics Views/install-EPP-views.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# if executing this script from the different folder as the views remove the # from the line below and update the path to the folder with the views
$pathToViews # = "c:\temp\EPP-PowerBI-Report-Starter-Kit\Starter Kit Support\Analytics Views"
# update the connection string to match your SQL server
$connectionString = "Data Source=.\SQL2017;Initial Catalog=EdFi_Ods;Integrated Security=True"

Try {
Write-Output "Creating Schema: Analytics"
Invoke-Sqlcmd -ConnectionString $connectionString -InputFile "Schema-Analytics-Create.sql"

Write-Output $pathToViews
if($null -eq $pathToViews) {
$pathToViews = $PSScriptRoot
}

$files = Get-ChildItem $pathToViews

foreach ($f in $files){
if (!$f.Name.Contains("Schema-Analytics-Create") -and $f.Name.Contains(".sql")) {
Write-Output "Installing view $f"
Invoke-Sqlcmd -ConnectionString $connectionString -InputFile $f.Name
}
}
Write-Output "Views installed successfully"
}
catch {}

0 comments on commit ceb07eb

Please sign in to comment.