protected override void PrepareSchema()
 {
     foreach (var c in _targetTable.Columns)
     {
         Schema[c.Name] = DbTypeMatching.GetClrType(c.SqlDbType);
     }
 }
        protected override void PrepareSchema()
        {
            foreach (var c in _targetTable.Columns)
            {
                Schema[c.Name] = DbTypeMatching.GetClrType(c.SqlDbType);
            }

            Schema[HistorySchema.HistoryStatusColumnName]    = typeof(string);
            Schema[HistorySchema.HistoryStampColumnName]     = typeof(DateTime);
            Schema[HistorySchema.HistoryLogColumnName]       = typeof(long);
            Schema[HistorySchema.HistoryFederatedColumnName] = typeof(bool);
            Schema[HistorySchema.HistoryAppliedColumnName]   = typeof(bool);
        }
Esempio n. 3
0
        private void GetMissingTablesAndColumns(
            SourceCompatibilityReport report,
            StagingTablesBuilder latestSchema,
            IReadOnlyList <string> tablesInStage,
            IReadOnlyList <string> tablesInSource)
        {
            foreach (var stageTable in tablesInStage)
            {
                if (!stageTable.Equals(StagingTablesBuilder.PseudoRegisterMarkTable, StringComparison.OrdinalIgnoreCase))
                {
                    // this table is not actually a member of the CT7 schema
                    if (!tablesInSource.Contains(stageTable, StringComparer.OrdinalIgnoreCase))
                    {
                        _log.ErrorFormat("Missing table {0}", stageTable);
                        report.AddMissingTable(stageTable);
                    }
                    else
                    {
                        // now check that the source columns exist...
                        var srcSchema      = GetSchemaForTable(stageTable);
                        var columnsInStage = latestSchema.GetColumns(stageTable);

                        foreach (var col in columnsInStage)
                        {
                            if (!col.Name.Equals(ColumnConstants.SrcTimetableIdColumnName, StringComparison.OrdinalIgnoreCase) &&
                                !col.Name.Equals(ColumnConstants.RegistersReqResolvedColumnName, StringComparison.OrdinalIgnoreCase))
                            {
                                var srcCol =
                                    srcSchema.FirstOrDefault(x => x.Name.Equals(col.Name, StringComparison.OrdinalIgnoreCase));
                                if (srcCol == null)
                                {
                                    _log.ErrorFormat("Missing column {0}.{1}", stageTable, col.Name);
                                    report.AddMissingColumn(stageTable, col.Name);
                                }
                                else if (!DbTypeMatching.
                                         MatchingDataTypes(srcCol.DataType, srcCol.CharacterMaxLength, col.SqlDbType, col.Length))
                                {
                                    _log.ErrorFormat("Incompatible data type for column {0}.{1}", stageTable, col.Name);
                                    report.BadDataType(stageTable, col.Name);
                                }
                            }
                        }
                    }
                }
            }
        }