Beispiel #1
0
        protected override void ConfigureUpgrade(IMigrationBuilder builder)
        {
            var db = Context.Container.Resolve <IConnectionMultiplexer>().GetDatabase();

            builder.Step("Update five", () =>
            {
                return(db.StringSetAsync("five", "5 up"));
            });

            builder.Step("Update seven", () =>
            {
                return(db.StringSetAsync("seven", "7 up"));
            });
        }
Beispiel #2
0
        protected override void ConfigureUpgrade(IMigrationBuilder builder)
        {
            var db = Context.Container.Resolve <IConnectionMultiplexer>().GetDatabase();

            builder.Step("Add thirteen", () =>
            {
                db.StringSetAsync("thirteen", "OMG OMG OMG");
            });
        }
Beispiel #3
0
        protected override void ConfigureUpgrade(IMigrationBuilder builder)
        {
            var db = ContextAs <PostgreSqlMigrationContext>().ConnectionProvider.Default();

            builder.Step("Add at column", async() =>
            {
                await db.ExecuteAsync(@"
                    alter table __Counter
                    add column At timestamp
                    ;");
            });

            builder.Step("Add bla column", async() =>
            {
                await db.ExecuteAsync(@"
                    alter table __Counter
                    add column bla text
                    ;");
            });
        }
Beispiel #4
0
        protected override void ConfigureUpgrade(IMigrationBuilder builder)
        {
            var db = ContextAs <PostgreSqlMigrationContext>().ConnectionProvider.Default();

            builder.Step("Add description column", async() =>
            {
                await db.ExecuteAsync(@"
                    alter table __Counter
                    add column Description text DEFAULT 'sample default value'
                    ;");
            });
        }
Beispiel #5
0
        protected override void ConfigureUpgrade(IMigrationBuilder builder)
        {
            var db = ContextAs <FuncMigrationContext>().Database;

            builder.Step("Add 'Mucho' to 'five'", async() =>
            {
                var kewl       = db.GetKewlById("five");
                kewl.Reference = $"Mucho {kewl.Reference}";

                db.UpsertKewl(kewl);
                await Task.CompletedTask;
            });

            builder.Step("Add 'Mucho' to 'seven'", async() =>
            {
                var kewl       = db.GetKewlById("seven");
                kewl.Reference = $"Mucho {kewl.Reference}";

                db.UpsertKewl(kewl);
                await Task.CompletedTask;
            });
        }
Beispiel #6
0
        protected override void ConfigureUpgrade(IMigrationBuilder builder)
        {
            var db = ContextAs <FuncMigrationContext>().Database;

            builder.Step("Add 'yay' to reference", () =>
            {
                foreach (var kewl in db.AllKewl())
                {
                    kewl.Reference = $"{kewl.Reference} yay";
                    db.UpsertKewl(kewl);
                }
            });
        }
Beispiel #7
0
        protected override void ConfigureUpgrade(IMigrationBuilder builder)
        {
            var db = ContextAs <MongoMigrationContext>().ConnectionProvider.Default();

            builder.Step("Add 'Mucho' to 'five'", async() =>
            {
                var filter = Builders <KewlEntityUpdated> .Filter.Eq(x => x.Reference, "5");

                var update = Builders <KewlEntityUpdated> .Update
                             .Set("Mucho", "Ulla Henriksen");

                await db.GetCollection <KewlEntityUpdated>().UpdateManyAsync(filter, update);
            });

            builder.Step("Add 'Mucho' to 'seven'", async() =>
            {
                var filter = Builders <KewlEntityUpdated> .Filter.Eq(x => x.Reference, "7");

                var update = Builders <KewlEntityUpdated> .Update
                             .Set("Mucho", "Bubbly");

                await db.GetCollection <KewlEntityUpdated>().UpdateManyAsync(filter, update);
            });
        }
Beispiel #8
0
        protected override void ConfigureUpgrade(IMigrationBuilder builder)
        {
            var db = ContextAs <MongoMigrationContext>().ConnectionProvider.Default();

            builder.Step("Change Reference from int to string", () =>
            {
                var collection = db.GetCollection <KewlEntity>(KewlEntity.Collection);

                var cursor = collection
                             .Find(_ => true)
                             .ToCursor();

                return(cursor.ForEachAsync(doc =>
                {
                    var filter = Builders <KewlEntityUpdated> .Filter.Eq(x => x.Id, doc.Id);
                    var update = Builders <KewlEntityUpdated> .Update.Set("Reference", doc.Reference.ToString());

                    db.GetCollection <KewlEntityUpdated>(KewlEntityUpdated.Collection).UpdateMany(filter, update);
                }));
            });
        }
Beispiel #9
0
 protected override void ConfigureUpgrade(IMigrationBuilder builder)
 {
     builder.Step("Throw!!", () => throw new InvalidOperationException("I should not be picked up and run"));
 }