Versionr.LocalDB.Upgrade C# (CSharp) Method

Upgrade() private method

private Upgrade ( ) : bool
return bool
        private bool Upgrade()
        {
            RefreshPartialPath();
            if (Configuration.Version != LocalDBVersion)
                Printer.PrintMessage("Upgrading local cache DB from version v{0} to v{1}", Configuration.Version, LocalDBVersion);
            else
                return true;
            PrepareTables();
            if (Configuration.Version < 5)
            {
                Configuration config = Configuration;
                config.Version = LocalDBVersion;
                try
                {
                    var fs = LoadFileTimes();
                    ReplaceFileTimes(fs);
                    BeginTransaction();
                    Update(config);
                    Commit();
                    ExecuteDirect("VACUUM");
                    return true;
                }
                catch
                {
                    Rollback();
                    return false;
                }
            }
            else if (Configuration.Version == 2)
            {
                Configuration config = Configuration;
                config.Version = LocalDBVersion;
                try
                {
                    BeginTransaction();
                    Update(config);
                    RefreshLocalTimes = true;
                    Commit();
                    return true;
                }
                catch
                {
                    Rollback();
                    return false;
                }
            }

            Configuration cconfig = Configuration;
            cconfig.Version = LocalDBVersion;
            try
            {
                BeginTransaction();
                Update(cconfig);
                Commit();
                return true;
            }
            catch
            {
                Rollback();
                return false;
            }
        }

Usage Example

Example #1
0
        public static LocalDB Open(string fullPath, bool headless)
        {
            LocalDB db = new LocalDB(fullPath, SQLite.SQLiteOpenFlags.ReadWrite | SQLite.SQLiteOpenFlags.FullMutex);

            if (!db.Upgrade(headless))
            {
                return(null);
            }
            return(db);
        }
All Usage Examples Of Versionr.LocalDB::Upgrade