generated from Ed-Fi-Exchange-OSS/Template-for-GitHub
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TPDMX-241/TPDMDEV-524 - PowerShell script to install views to SQL Ser…
…ver DB (#40) Adding script to create Analytics schema
- Loading branch information
1 parent
f9d73b5
commit ceb07eb
Showing
2 changed files
with
35 additions
and
0 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
Starter Kit Support/Analytics Views/Schema-Analytics-Create.sql
This file contains 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
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 |
This file contains 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
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 {} |