6

I have a folder in which I keep and maintain around 20 or MySQL script files, and I am currently managing version control using Git. Since these scripts are somewhat independent of each other version-wise, I would like to set my repo to track versioning on each file individually. For example, consider that I have the following:

ImportTableA.sql  -> v1.5
ProcessTableA.sql -> v1.2
TableAReport.sql  -> v2.1

After a bit of time and some mods are made to two of the files, and they appear like so:

ImportTableA.sql  -> v1.7
ProcessTableA.sql -> v1.2
TableAReport.sql  -> v3.0

Since the versioning and tags in Git apply to the repo as a whole, is there an easy way to track the version on the individual files? The only way that I can think of is to create a separate repo for each file, but that would be rather cumbersome to manage.

jedrzej.kurylo
  • 39,591
  • 9
  • 98
  • 107
Michael Sheaver
  • 2,059
  • 5
  • 25
  • 38
  • 2
    Why do you want to use git for this? rcs still works well. – jthill May 07 '16 at 18:33
  • Smudge|Clean filters. Or Mercurial with specially-crafted keyword for Keyword Extension. Or do not pull the owl on the globe and use common changeset-id for all files in repo – Lazy Badger May 08 '16 at 20:40

1 Answers1

1

Just add a comment with a version at the top of each file.

Ok, I'm joking. You are correct: having a separate repo (BTW, you could use submodules to incorporate them you in your main repo) for every file is rather cumbersome.

If it is possible to move that scripts inside a DB and manage them there (making them stored procedures), then you can use a DB migration tool. There are plenty of them. Liquibase and Flyway to name some. You'll still need to store migrations in Git.

madhead
  • 31,729
  • 16
  • 153
  • 201
  • Actually, you may have pointed me in the right direction; I am researching the use of submodules, and organizing the scripts into 4 submodules. Although they are not a perfect fit for this scenario, it appears that submodules may work. The only real snag I have found is that the git submodule add command assumes that the remote repo is already created. Not sure how create remote submodules from scratch. – Michael Sheaver May 08 '16 at 02:40