Esempio n. 1
0
        private static void CreateVersionInfo(DbConnection db)
        {
            using (var conn = db.Connect())
            {
                var sql = "CREATE TABLE `VersionInfo` (" +
                          "`Version` INTEGER NOT NULL, " +
                          "`AppliedOn` DATETIME DEFAULT CURRENT_TIMESTAMP, " +
                          "`Description` TEXT);";
                conn.Query(sql);

                sql = "CREATE UNIQUE INDEX IF NOT EXISTS `UC_Version` ON `VersionInfo` (`Version` ASC);";
                conn.Query(sql);
            }
        }
Esempio n. 2
0
        private static void CreateVersionInfo(DbConnection db)
        {
            using (var conn = db.Connect())
            {
                var sql = "CREATE TABLE `VersionInfo` (" +
                          "`Version` INTEGER NOT NULL, " +
                          "`AppliedOn` DATETIME DEFAULT CURRENT_TIMESTAMP, " +
                          "`Description` TEXT);";
                conn.Query(sql);

                sql = "CREATE UNIQUE INDEX IF NOT EXISTS `UC_Version` ON `VersionInfo` (`Version` ASC);";
                conn.Query(sql);
            }
        }
Esempio n. 3
0
        public void MigrateToLatest(DbConnection db)
        {
            var versionInfo = GetVersionInfo(db);

            var currentVersion = versionInfo != null ? versionInfo.Version : 0;

            using (var conn = db.Connect())
                using (var transaction = conn.BeginTransaction())
                {
                    do
                    {
                        currentVersion++;
                    } while (MigrateToVersion(conn, currentVersion));

                    transaction.Commit();
                }
        }
Esempio n. 4
0
        public void MigrateToLatest(DbConnection db)
        {
			var versionInfo = GetVersionInfo (db);

            var currentVersion = versionInfo != null ? versionInfo.Version : 0;

            using (var conn = db.Connect())
            using (var transaction = conn.BeginTransaction())
            {
                do
                {
                    currentVersion++;
                } while (MigrateToVersion(conn, currentVersion));

                transaction.Commit();
            }
        }
Esempio n. 5
0
        protected static VersionInfo GetVersionInfo(DbConnection db)
        {
            using (var conn = db.Connect())
            {
                var sql = "SELECT Version FROM `VersionInfo` ORDER BY Version DESC LIMIT 1";
                try
                {
                    return conn.Query<VersionInfo>(sql).FirstOrDefault();
                }
                catch (Exception e)
                {
                    if (!e.Message.Contains("no such table: VersionInfo"))
                        throw new Exception(e.Message, e);

                    CreateVersionInfo(db);
                    return conn.Query<VersionInfo>(sql).FirstOrDefault();
                }
            }
        }
Esempio n. 6
0
        protected static VersionInfo GetVersionInfo(DbConnection db)
        {
            using (var conn = db.Connect())
            {
                var sql = "SELECT Version FROM `VersionInfo` ORDER BY Version DESC LIMIT 1";
                try
                {
                    return(conn.Query <VersionInfo>(sql).FirstOrDefault());
                }
                catch (Exception e)
                {
                    if (!e.Message.Contains("no such table: VersionInfo"))
                    {
                        throw new Exception(e.Message, e);
                    }

                    CreateVersionInfo(db);
                    return(conn.Query <VersionInfo>(sql).FirstOrDefault());
                }
            }
        }