0

I work in a team developing a .NET code in VS environment as well as an Oracle database in PL/SQL. Now we want to use the Team Foundation Server as version control getting help of Oracle Developer Tool so that we can store both database and the code in one place. My question is that is there any possibility to "check in" the changes on both database and the code just by one tag? so that we realize in the future that those changes are related to one bug.

Narges
  • 47
  • 1
  • 7

3 Answers3

2

If you were using SQL Server you could use the Database Project functionality built into Visual Studio (aka SSDT / sqlproj).

For Oracle there are 3rd party tools that do a similar thing. The most popular ones are probably the RedGate tools.

Source Control for Oracle

Schema Compare for Oracle

Data Compare for Oracle

Dylan Smith
  • 22,069
  • 2
  • 47
  • 62
1

The simple fact is that you cannot treat the database objects as you treat your Java, C# or other files.

There are many reasons and I'll name a few:

Files are stored locally on the developer’s PC and the change s/he makes do not affect other developers. Likewise, the developer is not affected by changes made by her colleague. In database this is (usually) not the case and developers share the same database environment, so any change that were committed to the database affect others.

Publishing code changes is done using the Check-In / Submit Changes / etc. (depending on which source control tool you use). At that point, the code from the local directory of the developer is inserted into the source control repository. Developer who wants to get the latest code need to request it from the source control tool. In database the change already exists and impacts other data even if it was not checked-in into the repository.

During the file check-in, the source control tool performs a conflict check to see if the same file was modified and checked-in by another developer during the time you modified your local copy. Again there is no check for this in the database. If you alter a procedure from your local PC and at the same time I modify the same procedure with code form my local PC then we override each other’s changes.

The build process of code is done by getting the label / latest version of the code to an empty directory and then perform a build – compile. The output are binaries in which we copy & replace the existing. We don't care what was before. In database we cannot recreate the database as we need to maintain the data! Also the deployment executes SQL scripts which were generated in the build process.

When executing the SQL scripts (with the DDL, DCL, DML (for static content) commands) you assume the current structure of the environment match the structure when you create the scripts. If not, then your scripts can fail as you are trying to add new column which already exists.

Treating SQL scripts as code and manually generating them will cause syntax errors, database dependencies errors, scripts that are not reusable which complicate the task of developing, maintaining, testing those scripts. In addition, those scripts may run on an environment which is different from the one you though it would run on.

Sometimes the script in the version control repository does not match the structure of the object that was tested and then errors will happen in production!

There are many more, but I think you got the picture.

What I found that works is the following:

Use an enforced version control system that enforces check-out/check-in operations on the database objects. This will make sure the version control repository matches the code that was checked-in as it reads the metadata of the object in the check-in operation and not as a separated step done manually

Use an impact analysis that utilize baselines as part of the comparison to identify conflicts and identify if a change (when comparing the object's structure between the source control repository and the database) is a real change that origin from development or a change that was origin from a different path and then it should be skipped, such as different branch or an emergency fix.

An article I wrote on this was published here, you are welcome to read it.

DBAstep
  • 61
  • 4
0

TFS will let you check in any file, if it was a Sql Server database then you could have your c# code in one project and your sql code in another project in the same solution and then it would be really simple to check in all the code together.

Because there isn't a project type for PL/SQL you should export your schema / code to individual files which you could either add to a different type of project or not include them at all but just have them on the file system under a folder within the solution.

In TFS (VS 2013) the pending changes allows you to see either changes just within the solution i.e. files that are included in a project or all changes that happen in the file system under the solution so you can see all changes and then check them in with one check-in.

I often create additional folders under a visual studio solution with projects that can't be opened using visual studio and use other tools to manage them but use visual studio to check them into source control and it works really well.

For VS2013 - one thing to add is that when you check in, if the changes aren't shown in "Included Changes" - under "Excluded Changes" there is a button "Detected: XX add(s)" - if you go into that you can promote changes outside of the solution so that they are included.

Ed Elliott
  • 6,666
  • 17
  • 32
  • Also try and use Local Workspace (TFS 2012+ in conjunction with VS 2012+) so that files are not locked in your workspace thus enabling the use of 3rd party IDE/Editor to work unimpeded. The change will show up in the Pending changes in VS (like Ed mentioned) and you can check-in everything together like you want. – Etienne Jan 28 '15 at 15:34