Ejemplo n.º 1
0
            internal bool Upgrade(SchemaUpgradeTransactions transactions, int currentVersion, out int versionAfterUpgrade)
            {
                currentVersion = FixCurrentVersion(_storageType, currentVersion);

                switch (_storageType)
                {
                case StorageType.Server:
                    break;

                case StorageType.Configuration:
                    break;

                case StorageType.Documents:
                    if (SkippedDocumentsVersion.Contains(currentVersion))
                    {
                        throw new NotSupportedException($"Documents schema upgrade from version {currentVersion} is not supported, use the recovery tool to dump the data and then import it into a new database");
                    }
                    break;

                case StorageType.Index:
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(_storageType), _storageType, null);
                }

                versionAfterUpgrade = currentVersion;
                var updater = GetUpdater(_storageType, currentVersion);

                if (updater == null)
                {
                    return(false);
                }

                versionAfterUpgrade = updater.To;

                return(updater.Update(new UpdateStep(transactions)
                {
                    ConfigurationStorage = _configurationStorage,
                    DocumentsStorage = _documentsStorage,
                }));
            }
Ejemplo n.º 2
0
 public UpdateStep(SchemaUpgradeTransactions transactions)
 {
     _transactions = transactions;
 }
Ejemplo n.º 3
0
            internal bool Upgrade(SchemaUpgradeTransactions transactions, int currentVersion, out int versionAfterUpgrade)
            {
                switch (_storageType)
                {
                case StorageType.Server:
                    break;

                case StorageType.Configuration:
                    break;

                case StorageType.Documents:
                    if (SkippedDocumentsVersion.Contains(currentVersion))
                    {
                        throw new NotSupportedException($"Documents schema upgrade from version {currentVersion} is not supported, use the recovery tool to dump the data and then import it into a new database");
                    }
                    break;

                case StorageType.Index:
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(_storageType), _storageType, null);
                }

                versionAfterUpgrade = currentVersion;
                var name             = $"Raven.Server.Storage.Schema.Updates.{_storageType.ToString()}.From{currentVersion}";
                var schemaUpdateType = typeof(SchemaUpgrader).Assembly.GetType(name);

                if (schemaUpdateType == null)
                {
                    return(false);
                }

                versionAfterUpgrade++;

                switch (_storageType)
                {
                case StorageType.Server:
                    break;

                case StorageType.Configuration:
                    break;

                case StorageType.Documents:
                    while (SkippedDocumentsVersion.Contains(versionAfterUpgrade))
                    {
                        versionAfterUpgrade++;
                    }
                    break;

                case StorageType.Index:
                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(_storageType), _storageType, null);
                }

                var schemaUpdate = (ISchemaUpdate)Activator.CreateInstance(schemaUpdateType);

                return(schemaUpdate.Update(new UpdateStep(transactions)
                {
                    ConfigurationStorage = _configurationStorage,
                    DocumentsStorage = _documentsStorage
                }));
            }