Пример #1
0
        private async Task readIndexes(DbDataReader reader, Table existing)
        {
            await reader.NextResultAsync();

            while (await reader.ReadAsync())
            {
                if (await reader.IsDBNullAsync(2))
                {
                    continue;
                }

                var isPrimary = await reader.GetFieldValueAsync <bool>(6);

                if (isPrimary)
                {
                    continue;
                }

                var schemaName = await reader.GetFieldValueAsync <string>(1);

                var tableName = await reader.GetFieldValueAsync <string>(2);

                var ddl = await reader.GetFieldValueAsync <string>(4);


                if ((Identifier.Schema == schemaName && Identifier.Name == tableName) || Identifier.QualifiedName == tableName)
                {
                    var index = new ActualIndex(Identifier, await reader.GetFieldValueAsync <string>(3),
                                                ddl);

                    existing.Indexes.Add(index);
                }
            }
        }
Пример #2
0
        protected override SchemaPatchDifference compare(Table expected, Table actual)
        {
            if (actual == null)
            {
                return(SchemaPatchDifference.Create);
            }

            Columns = new ItemDelta <TableColumn>(expected.Columns, actual.Columns);
            Indexes = new ItemDelta <IIndexDefinition>(expected.Indexes, actual.Indexes,
                                                       (e, a) => ActualIndex.Matches(e, a, expected));

            ForeignKeys = new ItemDelta <ForeignKey>(expected.ForeignKeys, actual.ForeignKeys);

            PrimaryKeyDifference = SchemaPatchDifference.None;
            if (expected.PrimaryKeyName.IsEmpty())
            {
                if (actual.PrimaryKeyName.IsNotEmpty())
                {
                    PrimaryKeyDifference = SchemaPatchDifference.Update;
                }
            }
            else if (actual.PrimaryKeyName.IsEmpty())
            {
                PrimaryKeyDifference = SchemaPatchDifference.Create;
            }
            else if (!expected.PrimaryKeyColumns.SequenceEqual(actual.PrimaryKeyColumns))
            {
                PrimaryKeyDifference = SchemaPatchDifference.Update;
            }

            return(determinePatchDifference());
        }