1

We have table Items. Someone can add, update or delete rows. Final decision is made by a special person, for example, at the end of the working day. So this person wants to have history of changes and options like apply changes from John or merge John's and Walter's changes and apply or rollback to special state of table.

Is there a way to use VCS over Items table rows to have concepts like commits, branches, etc?

P.S. I already read about additional table: https://stackoverflow.com/a/323109/2620352, but it seems too inconvenient and wasteful.

Community
  • 1
  • 1
baratali
  • 443
  • 7
  • 16
  • 1
    You will need to build this version control into your system, both in the database and in your application. The closest you would get with a normal version control system would be to export the data into files, and version those, but it would not in any way integrate with your database or your application. In short, no, there is no way to use a normal VCS to do what you want. – Lasse V. Karlsen Aug 10 '14 at 16:16
  • @LasseV.Karlsen, with first line of your comment, I thought version control is possible for DB as well :) ... LOL – Rahul Aug 10 '14 at 16:17
  • 1
    Linked answer you have mentioned; is the only available solution you have on earth at present time unless in future some XYZ company comes with version control for DB. – Rahul Aug 10 '14 at 16:20
  • 1
    What I mean is that there is no existing version control system that works inside a database. They can version your table structure, and such, but if you require the system on a row-for-row basis, integrated into an application, you need to roll your own. – Lasse V. Karlsen Aug 10 '14 at 16:21
  • 1
    *“I already read about additional table but it seems too inconvenient and wasteful.”* – Even an existing versioned database system would have to store that information somewhere. Building your own system (into your application, on top of the database) is likely the more flexible and less wasteful solution than having a database in which *everything* was versioned. – poke Aug 10 '14 at 16:50

1 Answers1

3

You can (and must) version structure's changes.

Depending from used SQL-backend you can have more or less applicable tools, but, from my POV, Liquibase on top of your usual VCS is easiest and fastest way to start this process: it just add into revision, which contain changes in sources, additional file changeLog, which have all database-related elementary changes

Changelog (in any of possible formats) is text-file, thus - it can be easy diffed|merged

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110