johanclasson / vso-agent-tasks

Build and Release Tasks for Visual Studio Online and Team Foundation Server
MIT License
20 stars 16 forks source link

DbUpMigration - Scripts in subfolders #22

Closed m1nkeh closed 7 years ago

m1nkeh commented 7 years ago

Can't work out how to loop through all subfolders and run scripts in there too?

scripts/ scripts/folder1 scripts/folder2

something like $(System.DefaultWorkingDirectory)/Default/drop/Database/bin/Release/Scripts/* ?

thanks

johanclasson commented 7 years ago

I can think of two ways to do this.

1) In PowerShell, do Resolve-Path on the script dir and iterate each dir. That way you would be able to use regex-syntax similar to your suggestion.

2) I found that the WithScriptsFromFileSystem-method has an overload that makes it possible to specify if sub dirs should be included (and also an encoding option). https://github.com/DbUp/DbUp/blob/62f9c4fbbab1a3a4fc2db0beb6f9c35f6a92f019/src/DbUp/Builder/StandardExtensions.cs#L232

Which of these would you prefer?

m1nkeh commented 7 years ago

hmm.. not sure i have that much control do i? i am using the Dbup VSTS task, maybe i have misinterpreted...

for now, we have work around the solution with a build task that places all of the script items in a flat folder and this seems to work well

thinking about it more, it is probably dangerous to iterate through the files as if you have folders it is possible to have Script1.sql in multiple folders, and therefore they wouldn't get executed.

perp1exed commented 7 years ago

Yes, I am experiencing this also. Doesn't seem like it traverses subfolders to execute scripts.

Can someone confirm?

thanks.

perp1exed commented 7 years ago

Option 2 should be fine - I just want to be able to check an option which will make the task iterate subfolders.

thanks.

johanclasson commented 7 years ago

New version 0.12.0 available. I am interested to hear if you have any feedback!

The subdirectory support in DbUp I mentioned above was only for the next version of DbUp (4.0) which is still in development, and where still missing some important features. So I rolled my own solution to this problem instead.

If you choose to include scripts from subfolders, you can set the execution order sorted on either filename or file path. Scripts are journaled prefixed with their relative subpath, and thus if you have a script with the same name in two folders they will both be executed.

perp1exed commented 7 years ago

Sounds great - will let you know how it goes :)

regards,

Khurram

On 10 August 2017 at 03:00, Johan Classon notifications@github.com wrote:

New version 0.12.0 available. I am interested to hear if you have any feedback!

The subdirectory support in DbUp I mentioned above was only for the next version of DbUp (4.0) which is still in development, and where still missing some important features. So I rolled my own solution to this problem instead.

If you choose to include scripts from subfolders, you can set the execution order sorted on either filename or file path. Scripts are journaled prefixed with their relative subpath, and thus if you have a script with the same name in two folders they will both be executed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/johanclasson/vso-agent-tasks/issues/22#issuecomment-321468501, or mute the thread https://github.com/notifications/unsubscribe-auth/AVFNaw2mAYeOLV0aQ1cZwS940UIHbnklks5sWqqfgaJpZM4NKiCj .

m1nkeh commented 7 years ago

ok, this sounds superb... what we ended up doing in the end was "flatten" our structure with powerShell script so all the filenames were folder1_folder2_folder3_myscript.sql which serves it's purpose... this does however sound a lot better

perp1exed commented 7 years ago

Hi Johan,

Do I have to uninstall my TFS task and then reinstall? I do not see the new options so I assume somehow I must update the task.

thanks.

regards,

Khurram

On 10 August 2017 at 03:00, Johan Classon notifications@github.com wrote:

New version 0.12.0 available. I am interested to hear if you have any feedback!

The subdirectory support in DbUp I mentioned above was only for the next version of DbUp (4.0) which is still in development, and where still missing some important features. So I rolled my own solution to this problem instead.

If you choose to include scripts from subfolders, you can set the execution order sorted on either filename or file path. Scripts are journaled prefixed with their relative subpath, and thus if you have a script with the same name in two folders they will both be executed.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/johanclasson/vso-agent-tasks/issues/22#issuecomment-321468501, or mute the thread https://github.com/notifications/unsubscribe-auth/AVFNaw2mAYeOLV0aQ1cZwS940UIHbnklks5sWqqfgaJpZM4NKiCj .

johanclasson commented 7 years ago

No, @perp1exed. To install the latest version of the task should be sufficient. But since i fixed this issue I have released a new "Mayor version" of the task. I am thinking that this is what might be preventing you to see the new stuff.

VSTS has a feature that is does not upgrade existing tasks to new Mayor versions. To do that, search for "0.." in the task build/release editors and select "1.." instead!

perp1exed commented 7 years ago

Hmmm i'm using on-prem tfs so not sure how that would work.

I only see one dbup task and it does not include the changes.

Thanks,

Khurram

On Tue, Aug 22, 2017 at 12:05 PM Johan Classon notifications@github.com wrote:

No, @perp1exed https://github.com/perp1exed. To install the latest version of the task should be sufficient. But since i fixed this issue I have released a new "Mayor version" of the task. I am thinking that this is what might be preventing you to see the new stuff.

VSTS has a feature that is does not upgrade existing tasks to new Mayor versions. To do that, search for "0.." in the task build/release editors and select "1.." instead!

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/johanclasson/vso-agent-tasks/issues/22#issuecomment-324074044, or mute the thread https://github.com/notifications/unsubscribe-auth/AVFNa_OeaqayfPWKwamQIuvT1OU8IM0tks5savxOgaJpZM4NKiCj .

-- regards,

Khurram