public override DatabaseDefinition GetDatabaseDefinition() { var dd = new DatabaseDefinition(new MsSql2016TypeMapper(), new[] { GenericVersion.Generic1.GetTypeMapper() }); Log(LogSeverity.Debug, "Reading table definitions from database."); var module = "Reader/" + Executer.Generator.Version.UniqueName; var logTimer = new LogTimer(Logger, LogSeverity.Debug, "Reading table definitions from database.", module); foreach (var schemaAndTableName in GetSchemaAndTableNames()) { dd.AddTable(GetTableDefinition(schemaAndTableName, false)); } Log(LogSeverity.Debug, "Reading table documentation from database."); AddTableDocumentation(dd); Log(LogSeverity.Debug, "Reading table identities from database."); new MsSqlIdentityReader2016(Executer, SchemaNames).GetIdentity(dd); Log(LogSeverity.Debug, "Reading table indexes including primary keys and unique constraints from database."); new MsSqlIndexReader2016(Executer, SchemaNames).GetIndexes(dd); Log(LogSeverity.Debug, "Reading table foreign keys from database.", "Reader"); new MsSqlForeignKeyReader2016(Executer, SchemaNames).GetForeignKeys(dd); logTimer.Done(); return(dd); }
public static ApplicationDefinition Create() { ApplicationDefinition application = new ApplicationDefinition { Namespace = "ContosoUniversity" }; DatabaseDefinition database = new DatabaseDefinition { Name = "School" }; application.Databases.Add(database); database.AddTable(CourseTableDefinition()); database.AddTable(DepartmentTableDefinition()); database.AddTable(EnrollmentTableDefinition()); database.AddTable(InstructorTableDefinition()); database.AddTable(OfficeAssignmentTableDefinition()); database.AddTable(PersonTableDefinition()); database.AddTable(StudentTableDefinition()); application.Enumerations.Add(GradeDefinition()); return(application); }
private static void AddTable(DatabaseDefinition dd) { var newTable = new SqlTable { SchemaAndTableName = "NewTableToMigrate" }; newTable.AddInt32("Id", false).SetPK().SetIdentity(); new PrimaryKeyNamingDefaultStrategy().SetPrimaryKeyName(newTable.Properties.OfType <PrimaryKey>().First()); newTable.AddNVarChar("Name", 100); dd.AddTable(newTable); }
public override DatabaseDefinition GetDatabaseDefinition() { var dd = new DatabaseDefinition(new Oracle12cTypeMapper(), new[] { GenericVersion.Generic1.GetTypeMapper() }); Log(LogSeverity.Debug, "Reading table definitions from database."); foreach (var schemaAndTableName in GetSchemaAndTableNames()) { dd.AddTable(GetTableDefinition(schemaAndTableName, false)); } Log(LogSeverity.Debug, "Reading table identities from database."); new OracleIdentityReader12c(Executer, SchemaNames).GetIdentity(dd); Log(LogSeverity.Debug, "Reading table primary keys from database."); new OraclePrimaryKeyReader12c(Executer, SchemaNames).GetPrimaryKey(dd); Log(LogSeverity.Debug, "Reading table foreign keys including unique constrints from database.", "Reader"); new OracleForeignKeyReader12c(Executer, SchemaNames).GetForeignKeysAndUniqueConstrainsts(dd); Log(LogSeverity.Debug, "Reading indexes from database."); new OracleIndexReader12c(Executer, SchemaNames).GetIndexes(dd); return(dd); }
#pragma warning disable IDE1006 // Naming Styles public void _010_GenerateScriptAndCreateTable(SqlEngineVersion version) #pragma warning restore IDE1006 // Naming Styles { _sqlExecuterTestAdapter.Check(version); _sqlExecuterTestAdapter.InitializeAndCreate(version.UniqueName); var dd = new DatabaseDefinition(null, new[] { MsSqlVersion.MsSql2016.GetTypeMapper(), OracleVersion.Oracle12c.GetTypeMapper(), SqLiteVersion.SqLite3.GetTypeMapper() }); var table = new SqlTable("HierarchyFromCsvToSqlTests"); var column = table.AddInt32("Id"); column.Properties.Add(new Identity(column) { Increment = 1, Seed = 1 }); table.AddNVarChar("Name", 100); dd.AddTable(table); var context = new Context { Settings = TestHelper.GetDefaultTestSettings(version), Logger = TestHelper.CreateLogger() }; var generator = SqlGeneratorFactory.CreateGenerator(version, context); var sql = generator.CreateTable(table); var result = _sqlExecuterTestAdapter.ExecuteNonQuery(version.UniqueName, sql); if (result != null) { Assert.Inconclusive(result); } }