Beispiel #1
0
 private ToolStripItem CreateMigrationItem(MigrationType type)
 {
     return(new ToolStripMenuItem(type.ToString(), Resources.CSharpTransparent, ReserveMigrationNumber)
     {
         Tag = type
     });
 }
 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);
 }
Beispiel #3
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));
        }
Beispiel #4
0
        public IDatabase Create(MigrationType migrationType = MigrationType.Main, Action <NzbDroneMigrationBase> beforeMigration = null)
        {
            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, beforeMigration);

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

                return(dataMapper);
            });

            return(db);
        }
Beispiel #5
0
        public IDatabase Create(MigrationType migrationType = MigrationType.Main, Action<NzbDroneMigrationBase> beforeMigration = null)
        {
            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, beforeMigration);

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

                    return dataMapper;
                });

            return db;
        }
 private ToolStripItem CreateMigrationItem(MigrationType type)
 {
     return new ToolStripMenuItem(type.ToString(), Resources.CSharpTransparent, ReserveMigrationNumber) { Tag = type };
 }
Beispiel #7
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);
                }
            }
        }
 /// <summary>
 ///     Determines whether [is] [the specified migration type].
 /// </summary>
 /// <param name="migrationType">Type of the migration.</param>
 /// <returns>
 ///     <c>true</c> if [is] [the specified migration type]; otherwise, <c>false</c>.
 /// </returns>
 public bool Is(MigrationType migrationType)
 {
     return(string.Equals(MigrationType, migrationType.ToString(), StringComparison.CurrentCultureIgnoreCase));
 }
 private void LogMigrationMessage(MigrationType type)
 {
     _logger.Info("Starting migration of {0} DB to {1}", type.ToString(), Version);
 }