Example #1
0
 public static Revision GetMigratedRevision(int id, MigrationType type)
 {
     return(Current.DB.Query <Revision, QuerySet, Revision>(@"
         SELECT
             r.*, qs.*
         FROM
             Revisions r
         JOIN
             QueryMap qm
         ON
             r.Id = qm.RevisionId
         JOIN 
             QuerySets qs on qs.Id = r.OriginalQuerySetId 
         WHERE
             qm.OriginalId = @original AND
             MigrationType = @type", (r, q) =>
     {
         r.QuerySet = q;
         return r;
     },
                                                            new
     {
         original = id,
         type = (int)type
     }
                                                            ).FirstOrDefault());
 }
 public static string GetMigrationType(object endpoint)
 {
     if (endpoint is MigrationEndpoint)
     {
         MigrationType endpointType = ((MigrationEndpoint)endpoint).EndpointType;
         if (endpointType <= MigrationType.ExchangeOutlookAnywhere)
         {
             if (endpointType == MigrationType.IMAP)
             {
                 return("IMAP");
             }
             if (endpointType == MigrationType.ExchangeOutlookAnywhere)
             {
                 return("Staged");
             }
         }
         else
         {
             if (endpointType == MigrationType.ExchangeRemoteMove)
             {
                 return("RemoteMove");
             }
             if (endpointType == MigrationType.ExchangeLocalMove)
             {
                 return("LocalMove");
             }
             if (endpointType == MigrationType.PublicFolder)
             {
                 return("PublicFolder");
             }
         }
         throw new Exception("Unexpected endpoint type " + ((MigrationEndpoint)endpoint).EndpointType.ToString());
     }
     return("LocalMove");
 }
Example #3
0
        public void MigrateToLatest(string connectionString, MigrationType migrationType, Action <NzbDroneMigrationBase> beforeMigration)
        {
            var sw = Stopwatch.StartNew();

            _announcer.Heading("Migrating " + connectionString);

            var assembly = Assembly.GetExecutingAssembly();

            var migrationContext = new RunnerContext(_announcer)
            {
                Namespace          = "NzbDrone.Core.Datastore.Migration",
                ApplicationContext = new MigrationContext(migrationType, beforeMigration)
            };

            var options = new MigrationOptions {
                PreviewOnly = false, Timeout = 60
            };
            var factory   = new NzbDroneSqliteProcessorFactory();
            var processor = factory.Create(connectionString, _announcer, options);
            var runner    = new MigrationRunner(assembly, migrationContext, processor);

            runner.MigrateUp(true);

            sw.Stop();

            _announcer.ElapsedTime(sw.Elapsed);
        }
        public bool Migrate(DBContextBase dbContext, Tenant tenant, MigrationType migrationType)
        {
            var result = true;

            using (dbContext)
            {
                try
                {
                    var migrator = dbContext.GetService <IMigrator>();
                    if (migrationType == MigrationType.Down)
                    {
                        migrator.Migrate(Migration.InitialDatabase);
                    }
                    else
                    {
                        migrator.Migrate();
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    result = false;
                }
            }
            return(result);
        }
Example #5
0
 private ToolStripItem CreateMigrationItem(string text, MigrationType type)
 {
     return(new ToolStripMenuItem(text, Resources.CSharpTransparent, ReserveMigrationNumber)
     {
         Tag = type
     });
 }
Example #6
0
        private void ReserveMigrationNumber(MigrationType type)
        {
            try
            {
                var migrationNumber = _migrationNumberTrackerClient.ReserveMigrationNumber(Settings.Default.CurrentBranch, type);
                var migrationTuple  = new MigrationTuple
                {
                    MigrationType = type,
                    Number        = migrationNumber,
                };

                Settings.Default.LastResrevedMigration = migrationTuple;

                Settings.Default.Save();
                Clipboard.SetText(migrationNumber.ToMigrationPrefix());

                EnableUndo(migrationTuple);

                _mainIcon.ShowBalloonTip(2000,
                                         "Migration reserved successfully!",
                                         string.Format("Migration {0} reserved and copied to clipboard.", migrationTuple),
                                         ToolTipIcon.Info);
            }
            catch (Exception e)
            {
                HandleException(e);
            }
        }
        public void MigrateToLatest(string connectionString, MigrationType migrationType)
        {
            lock (MigrationCache)
            {
                if (MigrationCache.Contains(connectionString.ToLower())) return;

                _announcer.Heading("Migrating " + connectionString);

                var assembly = Assembly.GetExecutingAssembly();

                var migrationContext = new RunnerContext(_announcer)
                    {
                        Namespace = "NzbDrone.Core.Datastore.Migration",
                        ApplicationContext = new MigrationContext
                            {
                                MigrationType = migrationType,
                                SQLiteAlter = _sqLiteAlter,
                                MigrationHelper = _migrationHelper,
                            }
                    };

                var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
                var factory = new SqliteProcessorFactory();
                var processor = factory.Create(connectionString, _announcer, options);
                var runner = new MigrationRunner(assembly, migrationContext, processor);
                runner.MigrateUp(true);

                MigrationCache.Add(connectionString.ToLower());
            }
        }
Example #8
0
        void DetectMigrationType()
        {
            var first = _schemas[0];
            var last  = _schemas[_schemas.Count - 1];

            // we have more than one version
            if (first.Version != last.Version)
            {
                // get higher versions
                var higherVersions =
                    (from s in _schemas
                     where s.TypedVersion > first.TypedVersion
                     select s).ToList();
                // get lower versions
                var lowerVersions =
                    (from s in _schemas
                     where s.TypedVersion < first.TypedVersion
                     select s).ToList();
                if (higherVersions.Count > 0)
                {
                    _migrationType = MigrationType.Upgrade;
                    return;
                }
                if (lowerVersions.Count > 0)
                {
                    _migrationType = MigrationType.Rollback;
                    return;
                }
            }
            _migrationType = MigrationType.Install;
        }
Example #9
0
        public ManageManuallyWindow(MigrationNumberTrackerClient client, MainIcon icon)
        {
            InitializeComponent();

            const int initialTop         = 20;
            const int migrationBoxHeight = 40;
            const int initialLeft        = 10;

            var migrationTypes =
                Enum.GetValues(typeof(MigrationType)).Cast <MigrationType>().Except(new[] { MigrationType.None }).ToList();

            cbBranches.DisplayMember = "Name";
            cbBranches.ValueMember   = "Value";
            cbBranches.DataSource    =
                icon._branchProvider.GetAllRemoteBranches().Select(branch => new { Name = branch, Value = branch }).ToList();

            var currentBranch = Settings.Default.CurrentBranch;

            cbBranches.SelectedValue = currentBranch;

            for (int i = 0; i < migrationTypes.Count; ++i)
            {
                MigrationType migrationType = migrationTypes[i];
                grbxMigrations.Controls.Add(new MigrationBox(icon, client, migrationType, currentBranch)
                {
                    Top  = initialTop + migrationBoxHeight * i,
                    Left = initialLeft,
                });
            }
        }
Example #10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            WBFarm farm = WBFarm.Local;


            if (!IsPostBack)
            {
                MigrationType.DataSource = WBFarm.GetMigrationTypes();
                MigrationType.DataBind();
                MigrationType.WBxSafeSetSelectedValue(farm.MigrationType);

                MigrationSourceSystem.Text = farm.MigrationSourceSystem;

                MigrationControlListUrl.Text  = farm.MigrationControlListUrl;
                MigrationControlListView.Text = farm.MigrationControlListView;

                MigrationMappingListUrl.Text  = farm.MigrationMappingListUrl;
                MigrationMappingListView.Text = farm.MigrationMappingListView;

                MigrationSubjectsListUrl.Text  = farm.MigrationSubjectsListUrl;
                MigrationSubjectsListView.Text = farm.MigrationSubjectsListView;

                ItemsPerCycle.Text = farm.MigrationItemsPerCycle;

                UserName.Text     = farm.MigrationUserName;
                UserPassword.Text = "";
            }
        }
Example #11
0
        public void MigrateToLatest(string connectionString, MigrationType migrationType)
        {
            _announcer.Heading("Migrating " + connectionString);

            var assembly = Assembly.GetExecutingAssembly();

            var migrationContext = new RunnerContext(_announcer)
            {
                Namespace          = "NzbDrone.Core.Datastore.Migration",
                ApplicationContext = new MigrationContext
                {
                    MigrationType   = migrationType,
                    SQLiteAlter     = _sqLiteAlter,
                    MigrationHelper = _migrationHelper,
                }
            };

            var options = new MigrationOptions {
                PreviewOnly = false, Timeout = 60
            };
            var factory   = new SqliteProcessorFactory();
            var processor = factory.Create(connectionString, _announcer, options);
            var runner    = new MigrationRunner(assembly, migrationContext, processor);

            runner.MigrateUp(true);
        }
 public long ReadMigrationNumber(MigrationType type)
 {
     var client = new RestClient(Url);
     var request = new RestRequest("migrations/{type}", Method.GET);
     request.AddParameter("type", type, ParameterType.UrlSegment);
     var response = client.Execute(request);
     ThrowIfFailed(response);
     return GetLongOrThrow(response);
 }
Example #13
0
 internal MigrationInfo(MigrationType migrationType, ChaListDefine.CategoryNo category, string guidOld, string guidNew, int idOld, int idNew)
 {
     MigrationType = migrationType;
     Category      = category;
     GUIDOld       = guidOld;
     GUIDNew       = guidNew;
     IDOld         = idOld;
     IDNew         = idNew;
 }
Example #14
0
        public int CurrentVersion(MigrationType type)
        {
            var versions = _mapper.Fetch<DatabaseVersion>("where type = ?", (int) type).ToList();

            if (versions.Count == 0)
                return 0;

            return versions.Max(x => x.Version);
        }
 public long ReserveMigrationNumber(MigrationType type)
 {
     var client = new RestClient(Url);
     var request = new RestRequest("migrations/{type}/reserve", Method.POST) {RequestFormat = DataFormat.Json};
     request.AddParameter("type", type.ToString(), ParameterType.UrlSegment);
     var response = client.Execute(request);
     ThrowIfFailed(response);
     return GetLongOrThrow(response);
 }
 public void UpdateMigrationNumber(MigrationType type, long number)
 {
     var client = new RestClient(Url);
     var request = new RestRequest("migrations/{type}/{number}", Method.POST);
     request.AddParameter("type", type, ParameterType.UrlSegment);
     request.AddParameter("number", number, ParameterType.UrlSegment);
     var response = client.Execute(request);
     ThrowIfFailed(response);
 }
 public OrganizationIndex(IElasticConfiguration configuration)
     : base(configuration, Settings.Current.AppScopePrefix + "organization", 18)
 {
     AddType(OrganizationType = new OrganizationType(this));
     AddType(UserType         = new UserType(this));
     AddType(TokenType        = new TokenType(this));
     AddType(NotificationType = new NotificationType(this));
     AddType(MigrationType    = new MigrationType(this));
 }
Example #18
0
        public int CurrentVersion(MigrationType type)
        {
            var versions = _mapper.Fetch <DatabaseVersion>("where type = ?", (int)type).ToList();

            if (versions.Count == 0)
            {
                return(0);
            }

            return(versions.Max(x => x.Version));
        }
Example #19
0
    public override void FinalizeLoad()
    {
        MigrationDirection = (Direction)MigrationDirectionInt;
        MigrationType      = (MigrationType)MigrationTypeInt;

        base.FinalizeLoad();

        TargetCell = World.TerrainCells[TargetCellLongitude][TargetCellLatitude];

        Group.MigrationEvent = this;
    }
 public MigrationBox(MainIcon icon, MigrationNumberTrackerClient client, MigrationType type)
 {
     _icon = icon;
     _client = client;
     _type = type;
     InitializeComponent();
     lblMigrationType.Text = type + ":";
     RefreshData();
     _timer = new Timer {Interval = 3000};
     _timer.Tick += TimerTick;
 }
Example #21
0
        public long ReadMigrationNumber(string branch, MigrationType type)
        {
            var client  = new RestClient(Url);
            var request = new RestRequest("migrations/{encodedBranch}/{type}", Method.GET);

            request.AddParameter("encodedBranch", HttpUtility.UrlEncode(branch), ParameterType.UrlSegment);
            request.AddParameter("type", type, ParameterType.UrlSegment);
            var response = client.Execute(request);

            ThrowIfFailed(response);
            return(GetLongOrThrow(response));
        }
Example #22
0
 public FileMetadata(
     long sizeInBytes,
     MigrationType migrationType,
     string?version,
     string description)
 {
     SizeInBytes   = sizeInBytes;
     MigrationType = migrationType;
     VersionString = version;
     Version       = short.TryParse(version, out var parsed) ? parsed : (short)0;
     Description   = description;
 }
Example #23
0
        public void UpdateMigrationNumber(string branch, MigrationType type, long number)
        {
            var client  = new RestClient(Url);
            var request = new RestRequest("migrations/{encodedBranch}/{type}/{number}", Method.POST);

            request.AddParameter("encodedBranch", HttpUtility.UrlEncode(branch), ParameterType.UrlSegment);
            request.AddParameter("type", type, ParameterType.UrlSegment);
            request.AddParameter("number", number, ParameterType.UrlSegment);
            var response = client.Execute(request);

            ThrowIfFailed(response);
        }
Example #24
0
        public int CurrentVersion(MigrationType type)
        {
            var dbVersion = _mapper.FirstOrDefault<DatabaseVersion>("WHERE type = ?", (int)type);

            if (dbVersion == null)
            {
                _logger.Info("No entries in database version table. Defaulting version value to 0.");
                return 0;
            }

            return dbVersion.Version;
        }
Example #25
0
        public void ValidateInfo(MigrationOrigin origin, MigrationType type, string vatNumber, int year, string version, bool isValid)
        {
            IMigrationInfo info = new MigrationInfo()
            {
                Origin    = origin,
                Type      = type,
                Year      = year,
                VatNumber = vatNumber,
                Version   = version
            };

            info.IsValid().Should().Be(isValid);
        }
Example #26
0
 public MigrationBox(MainIcon icon, MigrationNumberTrackerClient client, MigrationType type, string branch)
 {
     _icon   = icon;
     _client = client;
     _type   = type;
     InitializeComponent();
     lblMigrationType.Text = type + ":";
     Branch = branch;
     RefreshData();
     _timer = new Timer {
         Interval = 3000
     };
     _timer.Tick += TimerTick;
 }
        public long MigrationNumber(string encodedBranch, MigrationType type)
        {
            var branch = HttpUtility.UrlDecode(encodedBranch);

            try
            {
                return(_provider.ReadMigrationNumber(branch, type));
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw HttpExceptionHelper.ServerError(e.Message);
            }
        }
Example #28
0
        public long ReserveMigrationNumber(string branch, MigrationType type)
        {
            var client  = new RestClient(Url);
            var request = new RestRequest("migrations/{encodedBranch}/{type}/reserve", Method.POST)
            {
                RequestFormat = DataFormat.Json
            };

            request.AddParameter("encodedBranch", HttpUtility.UrlEncode(branch), ParameterType.UrlSegment);
            request.AddParameter("type", type.ToString(), ParameterType.UrlSegment);
            var response = client.Execute(request);

            ThrowIfFailed(response);
            return(GetLongOrThrow(response));
        }
        public string MigrationNumber(string encodedBranch, MigrationType type, long number)
        {
            var branch = HttpUtility.UrlDecode(encodedBranch);

            try
            {
                _provider.UpdateMigrationNumber(branch, type, number);
            }
            catch (Exception e)
            {
                Log.Error(e);
                throw HttpExceptionHelper.ServerError(e.Message);
            }
            return("ok");
        }
        public void UpdateMigrationNumber(string branch, MigrationType type, long number)
        {
            var data = ReadData(branch);

            if (data.ContainsKey(type))
            {
                data[type] = number;
            }
            else
            {
                data.Add(type, number);
            }

            WriteData(branch, data);
        }
        public void UpdateMigrationNumber(MigrationType type, long number)
        {
            var data = ReadData();

            if (data.ContainsKey(type))
            {
                data[type] = number;
            }
            else
            {
                data.Add(type, number);
            }

            WriteData(data);
        }
Example #32
0
        public int CurrentVersion(MigrationType type)
        {
            var dbVersion = _conn.Perform(conn => conn.Select(conn.From<DatabaseVersion>()
                                .Where(x => x.Type == type)
                                .OrderByDescending(x => x.Version)
                                .Take(1)))
                                .FirstOrDefault();

            if (dbVersion == null)
            {
                _logger.Info("No entries in database version table. Defaulting version value to 0.");
                return 0;
            }

            return dbVersion.Version;
        }
Example #33
0
        public int CurrentVersion(MigrationType type)
        {
            var dbVersion = _conn.Perform(conn => conn.Select(conn.From <DatabaseVersion>()
                                                              .Where(x => x.Type == type)
                                                              .OrderByDescending(x => x.Version)
                                                              .Take(1)))
                            .FirstOrDefault();

            if (dbVersion == null)
            {
                _logger.Info("No entries in database version table. Defaulting version value to 0.");
                return(0);
            }

            return(dbVersion.Version);
        }
        public static void ProcessFile(string filePath, MigrationType migrationType)
        {
            var fileContents = File.ReadAllText(filePath);
            var sb           = new StringBuilder();
            var constructors = new List <string>();

            //      Look for matching patterns and replace with new values.
            foreach (var replacement in migrationType.Replacements.OrderBy(x => x.AddToConstructor))
            {
                if (fileContents.Contains(replacement.Old))
                {
                    fileContents = fileContents.Replace(replacement.Old, replacement.New);

                    // If the AddToConstructor value exists. Add to a separate string builder if not added already:
                    if (!string.IsNullOrEmpty(replacement.AddToConstructor) && !constructors.Contains(replacement.AddToConstructor))
                    {
                        if (sb.Length != 0)
                        {
                            sb.Append(", ");
                        }
                        sb.Append(replacement.AddToConstructor);
                        constructors.Add(replacement.AddToConstructor);
                    }
                }
            }

            var outputFolder = Path.Combine(Path.GetDirectoryName(filePath), "_output");

            if (!Directory.Exists(outputFolder))
            {
                Directory.CreateDirectory(outputFolder);
            }
            var outputPath = Path.Combine(outputFolder, Path.GetFileName(filePath));

            if (constructors.Count == 0)
            {
                File.WriteAllText(outputPath, fileContents);
                return;
            }

            var sb2 = new StringBuilder();

            sb2.Append(fileContents);
            sb2.AppendLine();
            sb2.AppendLine("constructor(" + sb.ToString() + ") {}");
            File.WriteAllText(outputPath, sb2.ToString());
        }
        public long ReserveMigrationNumber(MigrationType type)
        {
            var data = ReadData();

            if (data.ContainsKey(type))
            {
                ++data[type];
            }
            else
            {
                data.Add(type, DefaultMigrationNumber);
            }

            WriteData(data);

            return data[type];
        }
        public long ReserveMigrationNumber(string branch, MigrationType type)
        {
            var data = ReadData(branch);

            if (data.ContainsKey(type))
            {
                ++data[type];
            }
            else
            {
                data.Add(type, DefaultMigrationNumber);
            }

            WriteData(branch, data);

            return(data[type]);
        }
Example #37
0
        public static string ReadSql(Type migrationType, MigrationType migrationTypeEnum)
        {
            var    assembly     = migrationType.Assembly;
            string resourceName = $"{migrationType.Namespace}.scripts.{migrationType.Name}.{migrationTypeEnum.ToString()}.sql";

            using (System.IO.Stream stream = assembly.GetManifestResourceStream(resourceName))
            {
                if (stream == null)
                {
                    throw new FileNotFoundException("Unable to find the SQL file from an embedded resource", resourceName);
                }
                using (var reader = new StreamReader(stream))
                {
                    string content = reader.ReadToEnd();
                    return(content);
                }
            }
        }
Example #38
0
        public bool Migrate(DBContextBase dbContext, Tenant tenant, MigrationType migrationType)
        {
            var result = true;

            using (dbContext)
            {
                var migrator = dbContext.GetService <IMigrator>();
                if (migrationType == MigrationType.Down)
                {
                    migrator.Migrate(Migration.InitialDatabase);
                }
                else
                {
                    migrator.Migrate();
                }
            }

            return(result);
        }
Example #39
0
    public MigrateGroupEvent(
        CellGroup group,
        TerrainCell targetCell,
        Direction migrationDirection,
        MigrationType migrationType,
        long triggerDate,
        long originalSpawnDate = -1) :
        base(group, triggerDate, MigrateGroupEventId, originalSpawnDate: originalSpawnDate)
    {
        TargetCell = targetCell;

        TargetCellLongitude = TargetCell.Longitude;
        TargetCellLatitude  = TargetCell.Latitude;

        MigrationDirection = migrationDirection;
        MigrationType      = migrationType;

        DoNotSerialize = true;
    }
Example #40
0
    public void Reset(
        TerrainCell targetCell,
        Direction migrationDirection,
        MigrationType migrationType,
        long triggerDate)
    {
        TargetCell = targetCell;

        TargetCellLongitude = TargetCell.Longitude;
        TargetCellLatitude  = TargetCell.Latitude;

        MigrationDirection = migrationDirection;
        MigrationType      = migrationType;

        Reset(triggerDate);

        //		#if DEBUG
        //		GenerateDebugMessage ();
        //		#endif
    }
Example #41
0
        public IDatabase Create(MigrationType migrationType = MigrationType.Main)
        {
            string connectionString;


            switch (migrationType)
            {
                case MigrationType.Main:
                    {
                        connectionString = _connectionStringFactory.MainDbConnectionString;
                        break;
                    }
                case MigrationType.Log:
                    {
                        connectionString = _connectionStringFactory.LogDbConnectionString;
                        break;
                    }
                default:
                    {
                        throw new ArgumentException("Invalid MigrationType");
                    }
            }

            _migrationController.MigrateToLatest(connectionString, migrationType);

            var db = new Database(() =>
                {
                    var dataMapper = new DataMapper(SQLiteFactory.Instance, connectionString)
                    {
                        SqlMode = SqlModes.Text,
                    };

                    return dataMapper;
                });

            db.Vacuum();


            return db;
        }
Example #42
0
        public void MigrateToLatest(string connectionString, MigrationType migrationType, Action<NzbDroneMigrationBase> beforeMigration)
        {
            var sw = Stopwatch.StartNew();

            _announcer.Heading("Migrating " + connectionString);

            var assembly = Assembly.GetExecutingAssembly();

            var migrationContext = new RunnerContext(_announcer)
                {
                    Namespace = "NzbDrone.Core.Datastore.Migration",
                    ApplicationContext = new MigrationContext(migrationType, beforeMigration)
                };

            var options = new MigrationOptions { PreviewOnly = false, Timeout = 60 };
            var factory = new NzbDroneSqliteProcessorFactory();
            var processor = factory.Create(connectionString, _announcer, options);
            var runner = new MigrationRunner(assembly, migrationContext, processor);
            runner.MigrateUp(true);

            sw.Stop();

            _announcer.ElapsedTime(sw.Elapsed);
        }
Example #43
0
        private void ReserveMigrationNumber(MigrationType type)
        {
            try
            {
                var migrationNumber = _migrationNumberTrackerClient.ReserveMigrationNumber(type);
                var migrationTuple = new MigrationTuple
                    {
                        MigrationType = type,
                        Number = migrationNumber,
                    };

                Settings.Default.LastResrevedMigration = migrationTuple;

                Settings.Default.Save();
                Clipboard.SetText(migrationNumber.ToMigrationPrefix());

                EnableUndo(migrationTuple);

                _mainIcon.ShowBalloonTip(2000,
                    "Migration reserved successfully!",
                    string.Format("Migration {0} reserved and copied to clipboard.", migrationTuple),
                    ToolTipIcon.Info);
            }
            catch (Exception e)
            {
                HandleExceptionInHardcoreWay(e);
            }
        }
 public static Revision GetMigratedRevision(int id, MigrationType type)
 {
     return Current.DB.Query<Revision,QuerySet,Revision>(@"
         SELECT
             r.*, qs.*
         FROM
             Revisions r
         JOIN
             QueryMap qm
         ON
             r.Id = qm.RevisionId
         JOIN 
             QuerySets qs on qs.Id = r.OriginalQuerySetId 
         WHERE
             qm.OriginalId = @original AND
             MigrationType = @type",(r,q) => 
         {
             r.QuerySet = q;
             return r;
         },
         new
         {
             original = id,
             type = (int)type
         }
     ).FirstOrDefault();
 }
 public static Revision GetMigratedRevision(int id, MigrationType type)
 {
     return Current.DB.Query<Revision>(@"
         SELECT
             Revisions.*
         FROM
             Revisions
         JOIN
             QueryMap
         ON
             Revisions.Id = QueryMap.RevisionId
         WHERE
             QueryMap.OriginalId = @original AND
             MigrationType = @type",
         new
         {
             original = id,
             type = (int)type
         }
     ).FirstOrDefault();
 }
Example #46
0
 public MigrationContext(MigrationType migrationType, long? desiredVersion = null)
 {
     MigrationType = migrationType;
     DesiredVersion = desiredVersion;
 }
        public long ReadMigrationNumber(MigrationType type)
        {
            var data = ReadData();

            return data.ContainsKey(type) ? data[type] : DefaultMigrationNumber;
        }
Example #48
0
 protected Migration(MigrationType type, int version)
 {
     Type = type;
     Version = version;
 }
Example #49
0
 public IDatabase Create(MigrationType migrationType = MigrationType.Main)
 {
     return Create(new MigrationContext(migrationType));
 }
 public long ReserveMigrationNumber(MigrationType type)
 {
     return _provider.ReserveMigrationNumber(type);
 }
 public string MigrationNumber(MigrationType type, long number)
 {
     _provider.UpdateMigrationNumber(type, number);
     return "ok";
 }
Example #52
0
        public MigrationContext(MigrationType migrationType, Action<NzbDroneMigrationBase> beforeAction)
        {
            MigrationType = migrationType;

            BeforeMigration = beforeAction;
        }
Example #53
0
 private ToolStripItem CreateMigrationItem(string text, MigrationType type)
 {
     return new ToolStripMenuItem(text, Resources.CSharpTransparent, ReserveMigrationNumber) {Tag = type};
 }
 public bool MigrationRequired(MigrationType required)
 {
     return (Type & required) == required;
 }
 public long MigrationNumber(MigrationType type)
 {
     return _provider.ReadMigrationNumber(type);
 }