public SchemaBuilder CreateMapIndexTable(string name, Action <CreateTableCommand> table) { try { var createTable = new CreateTableCommand(Prefix(name)); var collection = CollectionHelper.Current; var documentTable = collection.GetPrefixedName(Store.DocumentTable); createTable .Column <int>("Id", column => column.PrimaryKey().Identity().NotNull()) .Column <int>("DocumentId"); table(createTable); Execute(_builder.CreateSql(createTable)); CreateForeignKey("FK_" + name, name, new[] { "DocumentId" }, documentTable, new[] { "Id" }); } catch { if (ThrowOnError) { throw; } } return(this); }
public ISchemaBuilder CreateMapIndexTable(Type indexType, Action <ICreateTableCommand> table, string collection) { try { var indexName = indexType.Name; var indexTable = TableNameConvention.GetIndexTable(indexType, collection); var createTable = new CreateTableCommand(Prefix(indexTable)); var documentTable = TableNameConvention.GetDocumentTable(collection); createTable .Column <int>("Id", column => column.PrimaryKey().Identity().NotNull()) .Column <int>("DocumentId"); table(createTable); Execute(_builder.CreateSql(createTable)); CreateForeignKey("FK_" + (collection ?? "") + indexName, indexTable, new[] { "DocumentId" }, documentTable, new[] { "Id" }); } catch { if (ThrowOnError) { throw; } } return(this); }
public SchemaBuilder CreateTable(string name, Action <CreateTableCommand> table) { try { var createTable = new CreateTableCommand(Prefix(name)); table(createTable); Execute(_builder.CreateSql(createTable)); } catch { if (ThrowOnError) { throw; } } return(this); }
public static IEnumerable <string> CreateSql(this ICommandInterpreter builder, ISchemaCommand command) { return(builder.CreateSql(new[] { command })); }