Can I trigger a commit via the command line?

I would like to be able to schedule source control commits on a daily basis.
Tagged:

Answers

  • @yantis It would help to understand what you are hoping to achieve in this. Why is this a problem for you? Automating commits is generally frowned upon as it could check in unfinished code. Also, it doesn't allow the developer the opportunity to type in a comment, which is important for the audit trail. 
    David Atkinson
    Product Manager
    Redgate Software
  • yantisyantis Posts: 5 New member
    David, good question.  Our context is a very active data warehouse team development environment where we like having the ability to go back to a version, of a view for instance, that we had yesterday.  So the purpose of the repository is not to track promotions.  We really just want frequent backups of our development work in case we delete something accidentally or just want to back up and start over on something.  I agree that it is an unusual case.

    Now, I just do commits 0 to 3 times a day as I think of it - and it has saved our bacon a few times.
  • @yantis

    In that case, can you please vote for this suggestion on our user voice forum? 
    Kind regards

    Tianjiao Li | Redgate Software
    Have you visited our Help Center?
  • David AtkinsonDavid Atkinson Posts: 1,431 Rose Gold 2
    edited January 18, 2019 2:17PM
    @yantis,

    If you want to achieve this, it should be possible, but you will need to write the scripts yourself. The good news is that it is trivially simple using the SQL Compare command line.

    Which version control tool do you use? These come with command lines, eg svn.exe, git.exe, etc.

    All you need to do is to use a scheduler (windows scheduler, an Agent Job, or even a CI tool - it doesn't matter) to run a script periodically. This script will do something like this:

    sqlcompare.exe /server1:<yourserver> /database1:<yourdb> /scripts2:<a_folder_location> /f

    (you will need to use any command line switches to take into account any comparison options you want. See  the docs for more details)

    This means that the folder <a_folder_location>, which must be placed in your VCS working folder, will be constantly updated with the latest schema. The rest of the script depends on your VCS command line. If using git it will be something like this:

    git stage .
    git commit -m "scheduled schema backup"
    git push origin master


    David Atkinson
    Product Manager
    Redgate Software
  • yantisyantis Posts: 5 New member
    Thanks David.  We use SVN.
  • @yantis

    This should be fairly simple. I found this page via a Google search that seems to cover all the SVN.exe commands.

    Let us know whether this solves the problem for you!
    David Atkinson
    Product Manager
    Redgate Software
  • yantisyantis Posts: 5 New member
    Yes, I have done some neat things with the SVN command line.  This is a very clever approach.  I will give it a shot.  Thanks again!
Sign In or Register to comment.