How to commit deleted objects

I have a development database that was identical to my master branch in Git.  Then I made a local branch in Git and went into SSMS and created 2 new functions and dropped 1 function.  I linked my development database and went to the commit tab, but it only showed the 2 functions I created, so I committed them. 

Now when I go into Git I can see the 2 functions I created and I can also see that the one I dropped is still there.  I have unlinked and relinked, but I can't get the dropped function to show up on the commit tab.

I fired up SQL Compare and sure enough if I compare the live database schema with what I have committed to the branch it shows that the dropped function is not present in the live database but is present in the local branch.

However, I can't figure out how to sync changes from a live database into source control using SQL Compare.  It just wants to make a tsql script, which isn't very relevant for making changes to source control.

I only have a week left on my evaluation and I thought I had figured everything out, but this one stumps me.

thx v much for your help,
kathy

Best Answer

  • KathyGKathyG Posts: 24 Bronze 1
    WayOutWest,

    Thx for your response, coming from the SSDT world I’m not used to linking.  Now that I know I’m supposed to stay linked that makes a lot more sense.  I haven’t seen any problems with the commit tab when I’ve been linked to the database while making modifications.

    thx v much

Answers

  • AlexYatesAlexYates Posts: 264 Rose Gold 2
    edited September 15, 2018 8:51AM
    Out of curiosity, does it erroneously show up in the Get Latest tab?

    You could try hand cranking it in raw git.

    Delete the stubborn file in the local git repo manually.

    Then, from the appropriate directory in the command prompt:

    > git status
    (to review your changes)

    Then:

    > git add .
    (Stages all manual file changes for commit. Alternatively you could specify specific changes.)

    > git commit -m "your message"
    (Commits the change locally)

    Then go back into SSMS/SQL Source Control and verify whether everything has sorted itself out.
    Alex Yates
    DevOps Mentor and Coach

    Director of DLM Consultants
    Creator of Speaking Mentors
    Microsoft Data Platform MVP
    Friend of Redgate
    Twitter / LinkedIn
  • KathyGKathyG Posts: 24 Bronze 1
    Alex,

    Thanks for your help.  I will try to do that today.  I’m very new to Git because prior to this redgate evaluation all of our database source control was implemented in TFS using SSDT.

    In addition to understanding SSC I’m also trying to master Git.  I’m using the Git interface in VSCode, and yes, I can see the function that was supposed to be dropped in my local branch.  I will manually use that interface to force the deletion of the function, then commit, then publish up to my remote branch in the VSCloud.

    1). Here’s a question for you Alex.   Do you know if I’m supposed to be able to use SQL Compare to sync changes from a live database into my local Git branch?  I haven’t figured out how to do that.

    2) Also ... here’s a question for Redgate Support:  I’ve seen other issues with SSC detecting deleted objects in both these forums and stack overflow.  Is this a problem with SSC and Git ?  I would like to get this issue resolved prior to the end of my evaluation.

    thx v much
  • KathyGKathyG Posts: 24 Bronze 1
    One more thing for Alex in response to the Get Latest tab.

    Yes ... I can see the function that I dropped in the Get Latest tab.
  • AlexYatesAlexYates Posts: 264 Rose Gold 2
    So how SoC* works out what should go into the commit vs the get latest tab is explained here:
    https://documentation.red-gate.com/soc6/reference-information/how-sql-source-control-works-behind-the-scenes

    (*Sorry, SSC means SqlServerCentral to most Redgate and ex-Redgate folks. SC is SQL Compare. SoC is SQL Source Control. No reason you would know that but it's a habbit that's hard for me to break!)

    Clearly in your case for some reason SoC has failed to work out whether the change was changed by someone else in source control and needs to be added to your database (Get Latest) or removed by you on the DB and a needs to be deleted in source control (Commit). That's why it shows up in the wrong tab. Removing it from your local repo manually should flush out the issue... I hope.

    Yes, you can use SQL Compare to diff the DB vs the files and deploy the DB version into the files. Then you would need to do the git add and commit manually as in my prior comment or through VS Code, rather than through SoC.
    Alex Yates
    DevOps Mentor and Coach

    Director of DLM Consultants
    Creator of Speaking Mentors
    Microsoft Data Platform MVP
    Friend of Redgate
    Twitter / LinkedIn
  • AlexYatesAlexYates Posts: 264 Rose Gold 2
    I'll let the (current) Redgate folks respond to the support issue since I don't work there any more.
    Alex Yates
    DevOps Mentor and Coach

    Director of DLM Consultants
    Creator of Speaking Mentors
    Microsoft Data Platform MVP
    Friend of Redgate
    Twitter / LinkedIn
  • KathyGKathyG Posts: 24 Bronze 1
    Thx Alex ... SoC, got it.
  • Hi,

    We are unaware of any particular issue with deleted objects.

    However if you are having any issues I suggest that you link SQL Source Control using the working folder method (and use a third party tool to commit/Pull).
    Sergio
    Product Support Engineer
    Redgate Software Ltd
    Please see our Help Center for detailed guides on how to use our tools
  • the order of when you do things sometimes becomes an issue. The idea with SOC is that it's always linked between your branch and the db. If you unlink, relink, you'll get into strange places. The goal here is to get changes from your VCS into the db first, since those can be made by other users, and then try to get your changes in there. In this case, I think you confused this by linking after doing work.

    The idea with a live database is that you are pulling to a blank VCS system, not using this to get changes to/from the VCS. That's a model that is fraught with issues.
Sign In or Register to comment.