Possible to combine a DBMS with git?

Hello!

Goal is to query a file by its unique id from a database. But additionally this file should be under version control to have the option of using a different/former state of it.
Is that possible at all?

There’s nothing in Git that prevents you from additionally storing files in another system, but there’s no built-in support. So you’d have to implement whatever connection you want between Git and your DB yourself.

One key question is probably going to be what to do in case of conflict between the state in both types of storage. I’m suspecting it might be easier to use just one type, but that really depends on your use case.

Thanks for the reply!

Use case is to use that file as action instruction, in other words as a testcase, to test a new software. The testframework queries this testcase by its id. So far so good. But the challenge is now to be able to possibly test a former software version with the corresponding testcase state. So this implies to run both, db and vcs.

Or is there an alternative to a db? Mandatory is to refer to the testcase by an id.

Personally I’d want to store testcase metadata (like IDs, descriptions, …) in Git with the implementations. The best way to do that will depend on the structure of your testsuite, and to some degree it’s a matter of taste. Possibilities that come to mind:

  • Put metadata in a comment in the implementation file (this only works well if you have one file per testcase)
  • Have one metadata file per test case
  • Have a global (for the repository) or per-directory metadata file, listing metadata for all testcases within

Likewise there are a lot of possible formats, I’d prefer something text based (e.g. YAML, JSON, CSV, …) so it’s easy to manage with Git. That way you can easily version your metadata along with the implementation.

If the testsuite is large it might be useful to create an index at runtime (and maybe store it in an SQLite DB or something) to make looking up testcases faster, but in my opinion that should only serve as a cache.