forked from ScottWeinstein/PSIS
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPrepareCode.ps1
48 lines (41 loc) · 2.48 KB
/
PrepareCode.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
function Prep($dest)
{
foreach ($file in (ls $dest))
{
(Get-Content $file.PSPath) | % {$_ -replace "USE \[DeploymentDB\]", "USE [DemoDb]"} | Set-Content $file.PSPath
}
}
function CopyAndPrepTable($source,$dest)
{
$ii = (@(ls $dest).Length) + 1
$files = ls $source
foreach ($file in $files)
{
$n = $file.Name
$d = "$dest\{0:0000}_$n" -f $ii++
cp $file.FullName $d
}
Prep $dest
}
function CopyAndPrep($source,$dest)
{
cp $source\* $dest
prep $dest
}
$AWDir = "C:\Users\Scott\Documents\d\CodePlex\PSIS\DDExtract"
$DSDir = "C:\Users\Scott\Documents\d\CodePlex\PSIS\DemoSource"
CopyAndPrepTable $AWDir\Schemas $DSDir\TableScripts
CopyAndPrepTable $AWDir\Tables $DSDir\TableScripts
$dirs = & { $args } UserDefinedDataTypes Views StoredProcedures UserDefinedDataTypes UserDefinedFunctions Views XmlSchemaCollections
foreach ($dir in $dirs)
{
if (! (Test-Path $DSDir\DemoDb\$dir\))
{
mkdir $DSDir\DemoDb\$dir\
}
CopyAndPrep $AWDir\$dir $DSDir\DemoDb\$dir\
}
#cp $AWDir\UserDefinedDataTypes\* $DSDir\DemoDb\UserDefinedDataTypes\
#cp $AWDir\Views\* $DSDir\DemoDb\Views\
#Prep $DSDir\DemoDb\UserDefinedDataTypes\
#Prep $DSDir\DemoDb\Views\