account for migration status in new Outputs...
This commit is contained in:
parent
9a2adc0d68
commit
fb1225060e
@ -1,20 +1,19 @@
|
||||
-- Generate Non-Duplicated PARENT FOLDER List
|
||||
DROP TABLE DataInventory;
|
||||
CREATE TABLE DataInventory AS
|
||||
Select *
|
||||
from (
|
||||
Select * from (
|
||||
SELECT SERVER,
|
||||
REPLACE(
|
||||
Parent,
|
||||
"X:\","\\mpe.ca\datadrive\") AS UNCPath,
|
||||
REPLACE(REPLACE(Parent,("\\mpe.ca\datadrive\" || Server),"/Shared/N-Data"),"\","/") AS EgnytePath,
|
||||
sum(FileCount) as FileCount, Sum(FileSize) as FileSize, 'Parent' as Source, Status from FolderData
|
||||
Where Parent in (
|
||||
SELECT Parent FROM NonDupParent
|
||||
)
|
||||
Where Parent in (
|
||||
SELECT Parent FROM NonDupParent
|
||||
)
|
||||
AND FolderData.fld_MigrationID IS NULL
|
||||
GROUP by UNCPath
|
||||
)
|
||||
|
||||
union
|
||||
SELECT SERVER,
|
||||
REPLACE(PATH,"X:\","\\mpe.ca\datadrive\") AS UNCPath,
|
||||
@ -22,6 +21,4 @@ SELECT SERVER,
|
||||
FileCount, FileSize, 'Project' as Source, Status from FolderData
|
||||
Where FolderData.Project in (
|
||||
SELECT Project FROM NonDupProject)
|
||||
-- AND FolderData.Parent in (
|
||||
-- Select Parent FROM NonDupParent
|
||||
-- );
|
||||
AND FolderData.fld_MigrationID IS NULL;
|
@ -135,15 +135,16 @@ $OfficeList | ForEach-Object -parallel {
|
||||
else {
|
||||
|
||||
$out = [PSCustomObject]@{
|
||||
Server = $Server
|
||||
Project = $ProjectNumber.ToString()
|
||||
Parent = $folder_Parent
|
||||
Path = $Path
|
||||
FileCount = $folder_FileCount
|
||||
FileSize = $folder_FileSize
|
||||
FileLastWrite = $folder_LastWrite
|
||||
FileLastAccess = $folder_LastAccess
|
||||
Status = $null # added to support Migration Status
|
||||
Server = $Server
|
||||
Project = $ProjectNumber.ToString()
|
||||
Parent = $folder_Parent
|
||||
Path = $Path
|
||||
FileCount = $folder_FileCount
|
||||
FileSize = $folder_FileSize
|
||||
FileLastWrite = $folder_LastWrite
|
||||
FileLastAccess = $folder_LastAccess
|
||||
Status = $null # added to support Migration Status
|
||||
fld_MigrationID = $null
|
||||
} | Out-DataTable
|
||||
|
||||
Invoke-SQLiteBulkCopy -DataSource $PathToDB_Copy -Table "FolderData" -DataTable $out -Force
|
||||
@ -193,8 +194,8 @@ foreach ($status in $MigrationStatus_import) {
|
||||
$SQLSourcePath += '\'
|
||||
}
|
||||
$SQLDestPath = $status.'Destination Path'.replace("'", "`'") #SQL Formatting
|
||||
if ($SQLDestPath -notmatch '\\$') {
|
||||
$SQLDestPath += '\'
|
||||
if ($SQLDestPath -notmatch '\/$') {
|
||||
$SQLDestPath += '/'
|
||||
}
|
||||
$SQLMigrationID = $status.'Migration ID'
|
||||
$SQLMigrationName = $status.'Migration Name'
|
||||
@ -208,14 +209,20 @@ foreach ($status in $MigrationStatus_import) {
|
||||
Invoke-SqliteQuery -DataSource $PathToDB -Query $Query
|
||||
}
|
||||
else {
|
||||
$Query = "INSERT INTO MigrationStatus VALUES ('$SQLMigrationID','$SQLMigrationName',`'$SQLSourcePath`',`'$SQLDestPath`','$SQLMigrationStatus')"
|
||||
$Query = "INSERT INTO MigrationStatus VALUES ('$SQLMigrationID','$SQLMigrationName',`'$SQLSourcePath`',`'$SQLDestPath`','$SQLMigrationStatus','')"
|
||||
Invoke-SqliteQuery -DataSource $PathToDB -Query $Query
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
# Update DB with new Data from MigrationStatus
|
||||
$Query = 'update FolderData SET fld_MigrationID = (SELECT MigrationID from MigrationStatus where Parent = MigrationFolderSource);'
|
||||
Invoke-SqliteQuery -DataSource $PathToDB -Query $Query
|
||||
|
||||
## DB Now contains MigrationID in fld_MigrationID Column. We can now reliably track the individual folder status'
|
||||
$query = "update FolderData set Status = (Select MigrationStatus from MigrationStatus where fld_MigrationID = MigrationID);"
|
||||
Invoke-SqliteQuery -DataSource $PathToDB -Query $Query
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user