public M201602092122_CreateECSCluster(MigrationContext context)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            _context = context;
            _client = CreateClient();
        }
        public M201512021606_CreatePostgreSQLDatabase(MigrationContext context)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            _context = context;
            _client = CreateClient();
        }
        public M201602092130_CreateECSWebTask(MigrationContext context)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            _context = context;
            _client = CreateClient();
            _task = _context.Settings.Cluster.GetTask("web");
        }
Example #4
0
 private IMigration CreateInstance(Type type, MigrationContext context)
 {
     var constructor = type.GetConstructor(new [] { typeof(MigrationContext) });
     if (constructor == null)
     {
         throw new InvalidOperationException($"Type '{type.FullName}' has no constructor accepting on parameter of type 'MigrationContext'");
     }
     return constructor.Invoke(new [] { context }) as IMigration;
 }
        public M201602102134_CreateEC2SecurityGroup(MigrationContext context)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            _context = context;
            _client = CreateClient();
            _cluster = _context.Settings.Cluster;
            _groupName = "securityGroup:" + _cluster.Name;
        }
Example #6
0
 private async Task Migrate(MigrationContext context, IEnumerable<Type> migrations, Func<IMigration, Task> action)
 {
     foreach (var migration in migrations.Select(type => CreateInstance(type, context)))
     {
         using (_logger.Scope("Execute migration: " + migration.GetType().Name))
         {
             await Migrate(migration, action);
         }
     }
 }
        public M201602102135_CreateEC2WebLoadBalancer(MigrationContext context)
        {
            if (context == null) throw new ArgumentNullException(nameof(context));

            _context = context;
            _client = CreateClient();
            _ec2client = CreateEc2Client();
            _cluster = _context.Settings.Cluster;
            _task = _cluster.GetTask("web");
        }
Example #8
0
        private Type[] GetMigrations(MigrationContext context)
        {
            var types = typeof(Runner)
                .GetTypeInfo()
                .Assembly
                .GetTypes()
                .Where(type => typeof(IMigration).IsAssignableFrom(type) && !type.GetTypeInfo().IsAbstract);

            var migrations = types.ToArray();

            _logger.WriteLine("Migrations found: " + migrations.Length);

            return migrations;
        }
Example #9
0
        static async void Main(string[] args)
        {
            var argument = ArgumentParser.Parse(args);
            var setting = new Settings(argument.Settings);
            var logger = new Logger();
            var context = new MigrationContext(logger, setting);
            var runner = new Runner(logger);

            if (argument.Command == MigrationCommand.Up)
            {
                await runner.Up(context);
            }
            else if (argument.Command == MigrationCommand.Down)
            {
                await runner.Down(context);
            }

            WaitForUserIfDebuggerAttached();
        }
Example #10
0
 public async Task Down(MigrationContext context)
 {
     var migrations = GetMigrations(context);
     await Migrate(context, migrations.Reverse(), migration => migration.Down());
 }
Example #11
0
 public async Task Up(MigrationContext context)
 {
     var migrations = GetMigrations(context);
     await Migrate(context, migrations, migration => migration.Up());
 }