コード例 #1
0
        /// <summary>
        /// Upgrades the database schema and data by running migrations.
        /// </summary>
        /// <remarks>
        /// <para>This assumes that the database exists and the connection string is
        /// configured and it is possible to connect to the database.</para>
        /// <para>Runs whichever migrations need to run.</para>
        /// </remarks>
        public Result UpgradeSchemaAndData()
        {
            try
            {
                var readyForInstall = CheckReadyForInstall();
                if (readyForInstall.Success == false)
                {
                    return(readyForInstall.Result);
                }

                _logger.Info <DatabaseBuilder>("Database upgrade started");

                var message = _scopeProvider.SqlContext.DatabaseType.IsMySql() ? ResultMessageForMySql : "";

                // upgrade
                var upgrader = new UmbracoUpgrader();
                upgrader.Execute(_scopeProvider, _migrationBuilder, _keyValueService, _logger, _postMigrations);

                message = message + "<p>Upgrade completed!</p>";

                //now that everything is done, we need to determine the version of SQL server that is executing

                _logger.Info <DatabaseBuilder>("Database configuration status: {DbConfigStatus}", message);

                return(new Result {
                    Message = message, Success = true, Percentage = "100"
                });
            }
            catch (Exception ex)
            {
                return(HandleInstallException(ex));
            }
        }
コード例 #2
0
        private void CreateKeyValueData()
        {
            // on install, initialize the umbraco migration plan with the final state

            var upgrader      = new UmbracoUpgrader();
            var stateValueKey = upgrader.StateValueKey;
            var finalState    = upgrader.Plan.FinalState;

            _database.Insert(Constants.DatabaseSchema.Tables.KeyValue, "key", false, new KeyValueDto {
                Key = stateValueKey, Value = finalState, Updated = DateTime.Now
            });
        }