English 中文(简体)
Web-App : Keeping trace of the version of the application in database?
原标题:

We are building a webapp which is shipped to several client as a debian package. Each client runs his own server. But the update and support is done by us. We make regular releases of the product, with a clean version number. Most of the users get an automatic update (by Puppet), some others don t.

We want to keep a trace of the version of the application (in order to allow the user to check the version in an "about" section, and for our support to help the user more accurately).

We plan to store the version of the code and the version of the base in our database, and to keep the info up to date automatically.

Is that a good idea ?

The other alternative we see is a file.

EDIT : The code and database schema are updated together. ( if we update to version x.y.z , both code and database go to x.y.z )

最佳回答

Using a table to track every change to a schema as described in this post is a good practice that I d definitely suggest to follow.

For the application, if it is shipped independently of the database (which is not clear to me), I d embed a file in the package (and thus not use the database to store the version of the web application).

If not and thus if both the application and the database versions are maintained in sync, then I d just use the information stored in the database.

问题回答

As a general rule, I would have both, DB version and application version. The problem here is how "private" is the database. If the database is "private" to the application, and user never modifies the schema then your initial solution is fine. In my experience, databases which accumulate several years of data stop being private, it means that users add a table or two and access data using some reporting tool; from that point on the database is not exclusively used by the application any more.

UPDATE

One more thing to consider is users (application) not being able to connect to the DB and calling for support. For this case it would be better to have version, etc.. stored on file system.

Assuming there are no compelling reasons to go with one approach or the other, I think I d go with keeping them in the database.

I d put them in both places. Then when running your about function you quickly check that they are both the same, and if they aren t you can display extra information about the version mismatch. If they re the same then you will only need to display one of them.

I ve generally found users can do "clever" things like revert databases back to old versions by manually copying directories around "because they can" so defensively dealing with it is always a good idea.





相关问题
what is wrong with this mysql code

$db_user="root"; $db_host="localhost"; $db_password="root"; $db_name = "fayer"; $conn = mysqli_connect($db_host,$db_user,$db_password,$db_name) or die ("couldn t connect to server"); // perform query ...

Users asking for denormalized database

I am in the early stages of developing a database-driven system and the largest part of the system revolves around an inheritance type of relationship. There is a parent entity with about 10 columns ...

Easiest way to deal with sample data in Java web apps?

I m writing a Java web app in my free time to learn more about development. I m using the Stripes framework and eventually intend to use hibernate and MySQL For the moment, whilst creating the pages ...

join across databases with nhibernate

I am trying to join two tables that reside in two different databases. Every time, I try to join I get the following error: An association from the table xxx refers to an unmapped class. If the ...

How can I know if such value exists in database? (ADO.NET)

For example, I have a table, and there is a column named Tags . I want to know if value programming exists in this column. How can I do this in ADO.NET? I did this: OleDbCommand cmd = new ...

Convert date to string upon saving a doctrine record

I m trying to migrate one of my PHP projects to Doctrine. I ve never used it before so there are a few things I don t understand. In my current code, I have a class similar to this: class ...

热门标签