diff --git a/DbUp.Support.SqlServer.Scripting.userprefs b/DbUp.Support.SqlServer.Scripting.userprefs new file mode 100644 index 0000000..6781ea8 --- /dev/null +++ b/DbUp.Support.SqlServer.Scripting.userprefs @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/build/Gemfile b/build/Gemfile deleted file mode 100644 index 3f80a9d..0000000 --- a/build/Gemfile +++ /dev/null @@ -1,4 +0,0 @@ -source 'http://rubygems.org' -gem 'albacore', '~>1.0' -gem 'nokogiri' -gem 'rake', '~>10.0' \ No newline at end of file diff --git a/build/Gemfile.lock b/build/Gemfile.lock deleted file mode 100644 index 74dc9ab..0000000 --- a/build/Gemfile.lock +++ /dev/null @@ -1,26 +0,0 @@ -GEM - remote: http://rubygems.org/ - specs: - albacore (1.0.0) - nokogiri (~> 1.5) - rake (~> 10.0) - rubyzip (~> 1.0) - mini_portile2 (2.1.0) - nokogiri (1.7.1-x64-mingw32) - mini_portile2 (~> 2.1.0) - nokogiri (1.7.1-x86-mingw32) - mini_portile2 (~> 2.1.0) - rake (10.5.0) - rubyzip (1.2.1) - -PLATFORMS - x64-mingw32 - x86-mingw32 - -DEPENDENCIES - albacore (~> 1.0) - nokogiri - rake (~> 10.0) - -BUNDLED WITH - 1.14.6 diff --git a/build/README.md b/build/README.md deleted file mode 100644 index aac5f65..0000000 --- a/build/README.md +++ /dev/null @@ -1,20 +0,0 @@ -**NOTE:** The build process should be done from Windows. Building from Mac/Linux is not supported currently. - -# Setup - -- cd `/build` -- Dowload latest [nuget.exe](https://nuget.org/nuget.exe) and save -- Run 'nuget SetApiKey' to add NuGet API Key to NuGet config -- Install Ruby -- Install Bundler: `gem install bundler` -- Run `bundle install` - -# Build - -- Build using Visual Studio using the "Release" configuration - -# Release to NuGet - -- cd `/build` -- Prepend line to `version.txt` with new version number and release notes -- Run `rake release` diff --git a/build/Rakefile b/build/Rakefile deleted file mode 100644 index 7a377fa..0000000 --- a/build/Rakefile +++ /dev/null @@ -1,50 +0,0 @@ -#DbUp.ConsoleScripts -#Example usage: rake release[1.2.0,"Release notes here..."] - -require 'albacore' -require 'date' -require 'net/http' -require 'openssl' - -project_id = "dbup-sqlserver-scripting" -project_name = "DbUp.Support.SqlServer.Scripting" -project_copyright = "Copyright #{DateTime.now.strftime('%Y')}" - -version_info = open("version.txt").gets.split(':') -version_number = version_info[0] -version_notes = version_info[1] - -task :restore do |t| - nugets_restore :restore do |p| - p.out = 'packages' - p.exe = 'tools/NuGet.exe' - end -end - -task :build do |t| - msbuild :build => [:restore] do |b| - b.solution = '..\\DbUp.Support.SqlServer.Scripting.sln' - b.targets = [ :Rebuild ] - b.properties = { :Configuration => 'Release' } - end -end - -task :package do |t, args| - desc "copy lib" - sh "xcopy /Y /S /EXCLUDE:exclude.txt ..\\#{project_name}\\bin\\Release\\#{project_name}* .\\pack\\lib\\net35\\" - desc "create the nuget package" - sh "nuget.exe pack .\\pack\\#{project_id}.nuspec -Properties \"version=#{version_number};notes=v#{version_number} - #{version_notes};copyright=#{project_copyright}\"" -end - -task :push do |t, args| - sh "nuget.exe push #{project_id}.#{version_number}.nupkg" -end - -task :tag do - sh "git tag -a v#{version_number} -m \"#{version_notes}\"" - sh "git push --tags" -end - -task :release => [:package, :push, :tag] do |t, args| - puts "v#{@version} Released!" -end \ No newline at end of file diff --git a/build/exclude.txt b/build/exclude.txt deleted file mode 100644 index b3b76c7..0000000 --- a/build/exclude.txt +++ /dev/null @@ -1 +0,0 @@ -.pdb \ No newline at end of file diff --git a/build/nuget.exe b/build/nuget.exe deleted file mode 100644 index 324daa8..0000000 Binary files a/build/nuget.exe and /dev/null differ diff --git a/build/version.txt b/build/version.txt deleted file mode 100644 index def7072..0000000 --- a/build/version.txt +++ /dev/null @@ -1,7 +0,0 @@ -1.5:Prevent functions from being scripted twice -1.3:New support for building database from scratch using new DefinitionScriptProvider -1.2:Added support for User Defined Types -1.1:Support for DbUp 3.3.4, misc bug fixes -1.0.4:Use dbup-consolescripts 1.0.9 and fix error with spaces in path -1.0.3:Showing entire path of scripted definiton file -1.0.2:Fixing error on ScriptAll \ No newline at end of file diff --git a/dbup-sqlserver-scripting.1.6.0/[Content_Types].xml b/dbup-sqlserver-scripting.1.6.0/[Content_Types].xml new file mode 100755 index 0000000..eadd7cb --- /dev/null +++ b/dbup-sqlserver-scripting.1.6.0/[Content_Types].xml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/dbup-sqlserver-scripting.1.6.0/_rels/.rels b/dbup-sqlserver-scripting.1.6.0/_rels/.rels new file mode 100755 index 0000000..7f58294 --- /dev/null +++ b/dbup-sqlserver-scripting.1.6.0/_rels/.rels @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/dbup-sqlserver-scripting.1.6.0/dbup-sqlserver-scripting.nuspec b/dbup-sqlserver-scripting.1.6.0/dbup-sqlserver-scripting.nuspec new file mode 100755 index 0000000..74675bb --- /dev/null +++ b/dbup-sqlserver-scripting.1.6.0/dbup-sqlserver-scripting.nuspec @@ -0,0 +1,23 @@ + + + + dbup-sqlserver-scripting + 1.6.0 + DbUp SQL Server Object Scripting + Brady Holt + Brady Holt + false + https://raw.github.com/bradyholt/dbup-sqlserver-scripting/master/LICENSE + https://github.com/bradyholt/dbup-sqlserver-scripting + https://raw.github.com/DbUp/DbUp/master/src/Information/dbup-icon.png + Extends DbUp to provide SQL Server object definition scripting when running migrations from Visual Studio. When a database object changes during a migration, its definition will be saved in the project. + v1.6.0 - Update library versions + Copyright 2017 + dbup database migrations sqlserver scripting definitions scripts console + + + + + + + \ No newline at end of file diff --git a/dbup-sqlserver-scripting.1.6.0/lib/net35/DbUp.Support.SqlServer.Scripting.dll b/dbup-sqlserver-scripting.1.6.0/lib/net35/DbUp.Support.SqlServer.Scripting.dll new file mode 100755 index 0000000..fa69691 Binary files /dev/null and b/dbup-sqlserver-scripting.1.6.0/lib/net35/DbUp.Support.SqlServer.Scripting.dll differ diff --git a/dbup-sqlserver-scripting.1.6.0/lib/net35/DbUp.Support.SqlServer.Scripting.dll.config b/dbup-sqlserver-scripting.1.6.0/lib/net35/DbUp.Support.SqlServer.Scripting.dll.config new file mode 100755 index 0000000..15bc4c6 --- /dev/null +++ b/dbup-sqlserver-scripting.1.6.0/lib/net35/DbUp.Support.SqlServer.Scripting.dll.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/dbup-sqlserver-scripting.1.6.0/lib/net35/DbUp.Support.SqlServer.Scripting.pdb b/dbup-sqlserver-scripting.1.6.0/lib/net35/DbUp.Support.SqlServer.Scripting.pdb new file mode 100755 index 0000000..96627ed Binary files /dev/null and b/dbup-sqlserver-scripting.1.6.0/lib/net35/DbUp.Support.SqlServer.Scripting.pdb differ diff --git a/dbup-sqlserver-scripting.1.6.0/package/services/metadata/core-properties/4dfc29f526184beca2892bca839033de.psmdcp b/dbup-sqlserver-scripting.1.6.0/package/services/metadata/core-properties/4dfc29f526184beca2892bca839033de.psmdcp new file mode 100755 index 0000000..88520da --- /dev/null +++ b/dbup-sqlserver-scripting.1.6.0/package/services/metadata/core-properties/4dfc29f526184beca2892bca839033de.psmdcp @@ -0,0 +1,9 @@ + + + Brady Holt + Extends DbUp to provide SQL Server object definition scripting when running migrations from Visual Studio. When a database object changes during a migration, its definition will be saved in the project. + dbup-sqlserver-scripting + 1.6.0 + dbup database migrations sqlserver scripting definitions scripts console + NuGet, Version=4.3.0.6, Culture=neutral, PublicKeyToken=31bf3856ad364e35;Unix 16.7.0.0;.NET Framework 4.5 + \ No newline at end of file diff --git a/build/pack/tools/dbup-sqlserver-scripting.psm1 b/dbup-sqlserver-scripting.1.6.0/tools/dbup-sqlserver-scripting.psm1 old mode 100644 new mode 100755 similarity index 100% rename from build/pack/tools/dbup-sqlserver-scripting.psm1 rename to dbup-sqlserver-scripting.1.6.0/tools/dbup-sqlserver-scripting.psm1 diff --git a/build/pack/tools/init.ps1 b/dbup-sqlserver-scripting.1.6.0/tools/init.ps1 old mode 100644 new mode 100755 similarity index 100% rename from build/pack/tools/init.ps1 rename to dbup-sqlserver-scripting.1.6.0/tools/init.ps1 diff --git a/build/pack/dbup-sqlserver-scripting.nuspec b/dbup-sqlserver-scripting.nuspec similarity index 100% rename from build/pack/dbup-sqlserver-scripting.nuspec rename to dbup-sqlserver-scripting.nuspec diff --git a/scripts/release.js b/scripts/release.js new file mode 100755 index 0000000..9b1b6c0 --- /dev/null +++ b/scripts/release.js @@ -0,0 +1,75 @@ +#!/usr/local/bin/jbash + +/* Releases dbup-sqlserver-scripting + This includes: building in release mode, packaging, and publishing on + NuGet, creating a GitHub release, uploading .nupkg to GitHub release. + + Example: + release.sh 2.0.0 "Fixed DOW bug causing exception" */ + +// Halt on an error +set("-e"); + +// cd to root dir +cd(`${__dirname}/../`); + +if (args.length != 2) { + echo(` +Usage: release.sh version "Release notes..." +Example: + release.js 2.0.0 "Fixed bug causing exception"`); + exit(1); +} + +if ($(`git status --porcelain`)) { + echo(`All changes must be committed first.`); + exit(1); +} + +let projectId = "dbup-sqlserver-scripting"; +let projectName = "DbUp.Support.SqlServer.Scripting"; +let version = args[0]; +let notes = args[1]; +let preRelease = version.indexOf("-") > -1; // If version contains a '-' character (i.e. 2.0.0-alpha-1) we will consider this a pre-release +let projectCopyright = `Copyright ${(new Date).getFullYear()}`; +let ghRepo = "bradyholt/dbup-sqlserver-scripting"; +let buildDirectory = "tmp"; + +// Restore NuGet pakcages and build in release mode +eval(`nuget restore`); +eval(`xbuild /property:Configuration=Release ${projectName}.sln`); + +// Create NuGet package +eval(`mkdir -p ${buildDirectory}/pack/lib/net35`) +eval(`cp dbup-sqlserver-scripting.nuspec tmp/pack`) +eval(`cp -r tools dbup-sqlserver-scripting.nuspec ${buildDirectory}/pack/`) +eval(`cp -r ${projectName}/bin/Release/${projectName}.* ${buildDirectory}/pack/lib/net35`) +eval(`nuget pack ${buildDirectory}/pack/${projectId}.nuspec -Properties "version=${version};notes=v${version} - ${notes};copyright=${projectCopyright}" -OutputDirectory ${buildDirectory}`) +let nupkgFile = `${buildDirectory}/${projectId}.${version}.nupkg`; + +// Push NuGet package +eval(`nuget push ${nupkgFile}`) + +// Commit changes to project file +eval(`git commit -am "New release: ${version}"`); + +// Create release tag +eval(`git tag -a ${version} -m "${notes}"`); +eval(`git push --follow-tags`); + +// Create release on GitHub +let response = $(`curl -f -H "Authorization: token ${env.GITHUB_API_TOKEN}" \ + -d '{"tag_name":"${version}", "name":"${version}","body":"${notes}","prerelease": ${preRelease}}' \ + https://api.github.com/repos/${ghRepo}/releases` +); + +let releaseId = JSON.parse(response).id; + +// Get the release id and then upload the and upload the .nupkg +eval(`curl -H "Authorization: token ${env.GITHUB_API_TOKEN}" -H "Content-Type: application/octet-stream" \ + --data-binary @"${nupkgFile}" \ + https://uploads.github.com/repos/${ghRepo}/releases/${releaseId}/assets?name=${nupkgFile}`); + +eval(`rm -r ${buildDirectory}`) + +echo(`DONE! Released version ${version} to NuGet and GitHub.`); \ No newline at end of file diff --git a/tmp/pack/dbup-sqlserver-scripting.nuspec b/tmp/pack/dbup-sqlserver-scripting.nuspec new file mode 100644 index 0000000..2c4dcf8 --- /dev/null +++ b/tmp/pack/dbup-sqlserver-scripting.nuspec @@ -0,0 +1,23 @@ + + + + dbup-sqlserver-scripting + $version$ + DbUp SQL Server Object Scripting + Brady Holt + Brady Holt + https://raw.github.com/bradyholt/dbup-sqlserver-scripting/master/LICENSE + https://github.com/bradyholt/dbup-sqlserver-scripting + https://raw.github.com/DbUp/DbUp/master/src/Information/dbup-icon.png + false + Extends DbUp to provide SQL Server object definition scripting when running migrations from Visual Studio. When a database object changes during a migration, its definition will be saved in the project. + $notes$ + $copyright$ + dbup database migrations sqlserver scripting definitions scripts console + + + + + + + diff --git a/tmp/pack/lib/net35/DbUp.Support.SqlServer.Scripting.dll b/tmp/pack/lib/net35/DbUp.Support.SqlServer.Scripting.dll new file mode 100644 index 0000000..fa69691 Binary files /dev/null and b/tmp/pack/lib/net35/DbUp.Support.SqlServer.Scripting.dll differ diff --git a/tmp/pack/lib/net35/DbUp.Support.SqlServer.Scripting.dll.config b/tmp/pack/lib/net35/DbUp.Support.SqlServer.Scripting.dll.config new file mode 100644 index 0000000..15bc4c6 --- /dev/null +++ b/tmp/pack/lib/net35/DbUp.Support.SqlServer.Scripting.dll.config @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/tmp/pack/lib/net35/DbUp.Support.SqlServer.Scripting.pdb b/tmp/pack/lib/net35/DbUp.Support.SqlServer.Scripting.pdb new file mode 100644 index 0000000..96627ed Binary files /dev/null and b/tmp/pack/lib/net35/DbUp.Support.SqlServer.Scripting.pdb differ diff --git a/tmp/pack/tools/dbup-sqlserver-scripting.psm1 b/tmp/pack/tools/dbup-sqlserver-scripting.psm1 new file mode 100644 index 0000000..88e1cb2 --- /dev/null +++ b/tmp/pack/tools/dbup-sqlserver-scripting.psm1 @@ -0,0 +1,52 @@ +<# Package Manager Console scripts to support DbUp #> + +function Start-DatabaseScript { + $project = Get-Project + Write-Host "Building..." + $dte.Solution.SolutionBuild.BuildProject("Debug", $project.FullName, $true) + $projectDirectory = Split-Path $project.FullName + $projectExe = $projectDirectory + "\bin\Debug\" + $project.Name + ".exe" + $args = " --scriptAllDefinitions" + + & $projectExe $args + } + + +function New-InitialScript { + + $project = get-project + $projectDirectory = Split-Path $project.FullName + #wrap in a job so type isn't locked + $job = Start-Job -ScriptBlock { + $basePath = $args[0] + $binDirectory = "$basePath\bin\debug" + try{ + Add-Type -Path "$binDirectory\DbUp.dll" + Add-Type -Path "$binDirectory\DbUp.Support.SqlServer.Scripting.dll" + } + catch + { + Write-Host -foreground yellow "LoadException"; + $Error | format-list -force + Write-Host -foreground red $Error[0].Exception.LoaderExceptions; + } + + $scriptProvider = new-object DbUp.Support.SqlServer.Scripting.DefinitionScriptProvider -ArgumentList "$basePath\Definitions" + $scriptProvider.GetScriptContent() + } -ArgumentList $projectDirectory + Wait-Job $job + + #create scripts folder if it doesn't exist + $scripts = $project.ProjectItems | ?{ $_.Name.Equals("Scripts") } + if($scripts -eq $null){ + $project.ProjectItems.AddFolder("Scripts") + } + #Create the new script by calling the lib + $initialScriptPath = "$projectDirectory\Scripts\001-initial.sql" + Receive-Job $job | New-Item $initialScriptPath -Force -ErrorAction Ignore -ItemType file + + #add to project + $addedItem = $project.ProjectItems.Item("Scripts").ProjectItems.AddFromFileCopy($initialScriptPath) + #update to embedded resource + $addedItem.Properties.Item("BuildAction").Value = 3 +} \ No newline at end of file diff --git a/tmp/pack/tools/init.ps1 b/tmp/pack/tools/init.ps1 new file mode 100644 index 0000000..252d5dc --- /dev/null +++ b/tmp/pack/tools/init.ps1 @@ -0,0 +1,3 @@ +param($installPath, $toolsPath, $package, $project) + +Import-Module (Join-Path $toolsPath dbup-sqlserver-scripting.psm1) \ No newline at end of file diff --git a/tools/dbup-sqlserver-scripting.psm1 b/tools/dbup-sqlserver-scripting.psm1 new file mode 100644 index 0000000..88e1cb2 --- /dev/null +++ b/tools/dbup-sqlserver-scripting.psm1 @@ -0,0 +1,52 @@ +<# Package Manager Console scripts to support DbUp #> + +function Start-DatabaseScript { + $project = Get-Project + Write-Host "Building..." + $dte.Solution.SolutionBuild.BuildProject("Debug", $project.FullName, $true) + $projectDirectory = Split-Path $project.FullName + $projectExe = $projectDirectory + "\bin\Debug\" + $project.Name + ".exe" + $args = " --scriptAllDefinitions" + + & $projectExe $args + } + + +function New-InitialScript { + + $project = get-project + $projectDirectory = Split-Path $project.FullName + #wrap in a job so type isn't locked + $job = Start-Job -ScriptBlock { + $basePath = $args[0] + $binDirectory = "$basePath\bin\debug" + try{ + Add-Type -Path "$binDirectory\DbUp.dll" + Add-Type -Path "$binDirectory\DbUp.Support.SqlServer.Scripting.dll" + } + catch + { + Write-Host -foreground yellow "LoadException"; + $Error | format-list -force + Write-Host -foreground red $Error[0].Exception.LoaderExceptions; + } + + $scriptProvider = new-object DbUp.Support.SqlServer.Scripting.DefinitionScriptProvider -ArgumentList "$basePath\Definitions" + $scriptProvider.GetScriptContent() + } -ArgumentList $projectDirectory + Wait-Job $job + + #create scripts folder if it doesn't exist + $scripts = $project.ProjectItems | ?{ $_.Name.Equals("Scripts") } + if($scripts -eq $null){ + $project.ProjectItems.AddFolder("Scripts") + } + #Create the new script by calling the lib + $initialScriptPath = "$projectDirectory\Scripts\001-initial.sql" + Receive-Job $job | New-Item $initialScriptPath -Force -ErrorAction Ignore -ItemType file + + #add to project + $addedItem = $project.ProjectItems.Item("Scripts").ProjectItems.AddFromFileCopy($initialScriptPath) + #update to embedded resource + $addedItem.Properties.Item("BuildAction").Value = 3 +} \ No newline at end of file diff --git a/tools/init.ps1 b/tools/init.ps1 new file mode 100644 index 0000000..252d5dc --- /dev/null +++ b/tools/init.ps1 @@ -0,0 +1,3 @@ +param($installPath, $toolsPath, $package, $project) + +Import-Module (Join-Path $toolsPath dbup-sqlserver-scripting.psm1) \ No newline at end of file