Database schema updates

前端 未结 4 1012
情深已故
情深已故 2021-02-01 06:56

I\'m working on an AIR application that uses a local SQLite database and was wondering how I could manage database schema updates when I distribute new versions of the applicati

4条回答
  •  猫巷女王i
    2021-02-01 07:34

    What I am considering is adding a SchemaVersion table to the database which holds a record for every version that exists. The last version of the SchemaVersion table is the current level of the database.

    I am going to create (SQL) scripts that perform the initial setup of 1.0 and thereafter the upgrade from 1.0 to 1.1, 1.1 to 1.2, etc.

    Even a fresh install to e.g. 1.2 will run through all these scripts. This might seem a little slow, but is only done once and on an (almost) empty database.

    The big advantage of this is that a fresh install will have the same database schema as an upgraded install.

    As I said: I am considering this. I will probably start implementing this tomorrow. If you're interested I can share my experiences. I will be implementing this for a c# application that uses LINQ-to-entities with SQL Server and MySQL as DBMSes.

    I am interested to hear anybody else's suggestions and ideas and if somebody can point me out an open source .Net library or classes that implements something like this, that would be great.

    EDIT: In the answer to a different question here on SO I found a reference to Migrator.Net. I started using it today and it looks like it is exactly what I was looking for.

提交回复
热议问题