Beispiel #1
0
        public void do_not_drop_unchanged_index()
        {
            EnableCommandLogging = true;

            StoreOptions(_ =>
            {
                _.AutoCreateSchemaObjects = AutoCreate.CreateOrUpdate;
                _.DdlRules.TableCreation  = CreationStyle.CreateIfNotExists;
                _.Schema.For <Bug1043.Thing>().Index(x => x.Name, x =>
                {
                    x.IndexName    = "Test_Index";
                    x.IsUnique     = true;
                    x.Casing       = ComputedIndex.Casings.Lower;
                    x.IsConcurrent = true;
                });
            });

            using (var session = theStore.OpenSession())
            {
                session.Insert(new Bug1043.Thing
                {
                    Id    = "test/1",
                    Name  = "A Thing",
                    Count = 1
                });

                session.SaveChanges();
            }

            var mapping = DocumentMapping.For <Bug1043.Thing>();

            mapping.Index(x => x.Name, x =>
            {
                x.IndexName    = "Test_Index";
                x.IsUnique     = true;
                x.Casing       = ComputedIndex.Casings.Lower;
                x.IsConcurrent = true;
            });
            var docTable = new DocumentTable(mapping);

            using (var connection = new Npgsql.NpgsqlConnection(ConnectionSource.ConnectionString))
            {
                connection.Open();

                var diff = docTable.FetchDelta(connection);

                Assert.NotNull(diff);
                Assert.Equal(0, diff.IndexChanges.Count);
                Assert.Equal(0, diff.IndexRollbacks.Count);
            }
        }
Beispiel #2
0
        public void can_spot_an_extra_index()
        {
            theMapping.Index(x => x.UserName);

            writeTable();

            theMapping.Index(x => x.FirstName);
            var table = new DocumentTable(theMapping);

            var delta = table.FetchDelta(_conn);

            delta.IndexChanges.Count.ShouldBe(1);
            delta.IndexRollbacks.Count.ShouldBe(1);
        }