-
-
Save steveoh/9ad816c2b8e56b57ef79 to your computer and use it in GitHub Desktop.
Create a class and add it to solution
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
param([string]$migration = "0", [string]$projectName="UDAF.DB.Migrations") | |
$date = (get-date).ToString("yyyMMddhhmmss") | |
$className = "MigrationFor"+$migration+"_"+$date | |
$fileName = "$className.cs" | |
$project | |
Write-Host "Looking for project" $projectName | |
$i = 0 | |
while($project.ProjectName -ne $projectName) | |
{ | |
$i++ | |
$project = $dte.Solution.Projects.Item($i) | |
} | |
Write-Host "found project at index $i" | |
if($i -gt $dte.Solution.Projects.Count) | |
{ | |
Write-Host "Project not found, quitting." | |
exit | |
} | |
$path = [System.IO.Path]::GetDirectoryName($project.FullName)+"\"+$fileName | |
Write-Host "saving file to" $path | |
$file = New-Item $path -type file -value "using FluentMigrator; | |
namespace $projectName | |
{ | |
/// <summary> | |
/// | |
/// </summary> | |
[Migration($date)] | |
public class $className : Migration | |
{ | |
private const string User = `"SALINITYADMIN`", Table = `"`", Column = `"`"; | |
public override void Up() | |
{ | |
} | |
public override void Down() | |
{ | |
} | |
} | |
}" | |
$project.ProjectItems.AddFromFile($file) | |
Write-Host "Migration added to project" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment