public ApplyCommand( ISchemaManager schemaManager, ILogger <ApplyCommand> logger) : base(CommandNames.Apply, Resources.ApplyCommandDescription) { AddOption(CommandOptions.ConnectionStringOption()); AddOption(CommandOptions.ServerOption()); AddOption(CommandOptions.VersionOption()); AddOption(CommandOptions.NextOption()); AddOption(CommandOptions.LatestOption()); AddOption(CommandOptions.ForceOption()); Handler = CommandHandler.Create( (string connectionString, Uri server, MutuallyExclusiveType type, bool force, CancellationToken token) => HandlerAsync(connectionString, server, type, force, token)); Argument.AddValidator(symbol => RequiredOptionValidator.Validate(symbol, CommandOptions.ConnectionStringOption(), Resources.ConnectionStringRequiredValidation)); Argument.AddValidator(symbol => RequiredOptionValidator.Validate(symbol, CommandOptions.ServerOption(), Resources.ServerRequiredValidation)); Argument.AddValidator(symbol => MutuallyExclusiveOptionValidator.Validate(symbol, new List <Option> { CommandOptions.VersionOption(), CommandOptions.NextOption(), CommandOptions.LatestOption() }, Resources.MutuallyExclusiveValidation)); EnsureArg.IsNotNull(logger, nameof(logger)); EnsureArg.IsNotNull(schemaManager, nameof(schemaManager)); _logger = logger; _schemaManager = schemaManager; }
public SetUpEventHandler( ISchemaBuilder schemaBuilder, ISchemaManager schemaManager) { _schemaBuilder = schemaBuilder; _schemaManager = schemaManager; }
public FeatureEventHandler( ISchemaBuilder schemaBuilder, ISchemaManager schemaManager) { _schemaBuilder = schemaBuilder; _schemaManager = schemaManager; }
public UIController(IConfiguration configuration, IEnumerable <ILookupProvider> lookupProviders, ISchemaManager schemaManager) { this.configuration = configuration; this.schemaManager = schemaManager; this.lookupProviders = lookupProviders.ToList(); }
public FullTextIndexCommand( ISchemaBuilder schemaBuilder, ISchemaManager schemaManager, ICacheManager cacheManager) { _schemaBuilder = schemaBuilder; _schemaManager = schemaManager; _cacheManager = cacheManager; }
public SetUpEventHandler( IDefaultRolesManager defaultRolesManager, ISchemaBuilder schemaBuilder, ISchemaManager schemaManager) { _defaultRolesManager = defaultRolesManager; _schemaBuilder = schemaBuilder; _schemaManager = schemaManager; }
public SessionService( IConnectionStringService connectionStringService, ISchemaManager schemaManagerService, ISchemaTreeBuilder schemaTreeBuilder) { _connectionStringService = connectionStringService; _schemaManagerService = schemaManagerService; _schemaTreeBuilder = schemaTreeBuilder; }
protected DbTable(DbSession session, ISchemaManager schemaManager, object shardObject, object partitionObject, IShardStrategy shardStrategy) : base(session) { this.SchemaManager = schemaManager; this.ShardObject = shardObject; this.PartitionObject = partitionObject; this.ShardStrategy = shardStrategy; string tableName = this.EntityType.Name; if (this.SchemaManager != null) { this.Schema = this.SchemaManager.GetSchema <TEntity>(); if (this.Schema != null) { tableName = this.Schema.TableName; } } if (this.Schema == null) { this.Schema = SchemaParser.GetSchema <TEntity>(); if (this.Schema != null) { tableName = this.Schema.TableName; } } if (this.Schema == null) { throw new InvalidOperationException($"Cannot parse entity '{this.EntityType}'s schema."); } this.TableName = tableName; if (this.ShardStrategy != null) { string tableShardNo = this.ShardStrategy.GetTableShardNo(tableName, this.ShardObject); if (!string.IsNullOrWhiteSpace(tableShardNo)) { this.TableName += ("_" + tableShardNo.Trim()); } string tablePartitionNo = this.ShardStrategy.GetTablePartitionNo(tableName, this.ShardObject, this.PartitionObject); if (!string.IsNullOrWhiteSpace(tablePartitionNo)) { this.TableName += ("_" + tablePartitionNo.Trim()); } } this.QueryContext = new DbQueryContext(session); this.QueryContext.SetFrom <TEntity>(this); }
private string GetSchemaName(ISchemaManager manager, Guid itemUid) { var schemaName = string.Empty; var schema = manager.FindItemByUId(itemUid); if (schema != null) { schemaName = schema.Name; } return(schemaName); }
internal void Initialize(bool master, ISchemaManager schemaManager, object shardObject, IShardStrategy shardStrategy, IConnectionManager connectionManager) { this.UsingMaster = master; this.SchemaManager = schemaManager; this.ShardObject = shardObject; this.ShardStrategy = shardStrategy; this.ConnectionManager = connectionManager; }
private static void WarmupManager <TM, TS>(ISchemaManager schemaManager) where TM : ISchemaManager where TS : Schema, ISchemaManagerSchema <TS> { var typeSchemaManager = (TM)schemaManager; var schemaManagerItems = typeSchemaManager.GetItems(); foreach (SchemaManagerItem <TS> item in schemaManagerItems) { Schema instance = item.Instance; } }
public SetUpEventHandler( IUserColorProvider userColorProvider, UserManager <User> userManager, RoleManager <Role> roleManager, ISchemaManager schemaManager, ISchemaBuilder schemaBuilder) { _userColorProvider = userColorProvider; _schemaBuilder = schemaBuilder; _schemaManager = schemaManager; _userManager = userManager; _roleManager = roleManager; }
public SetUpEventHandler( ISchemaBuilder schemaBuilder, IDefaultRolesManager defaultRolesManager, UserManager <User> userManager, RoleManager <Role> roleManager, ISchemaManager schemaManager) { _schemaBuilder = schemaBuilder; _defaultRolesManager = defaultRolesManager; _userManager = userManager; _roleManager = roleManager; _schemaManager = schemaManager; }
public UIController(IConfiguration configuration, ILookupManager lookupManager, ITypeResolver typeResolver, ISchemaManager schemaManager, ICubesEnvironment cubesEnvironment, IServiceScopeFactory scopeFactory) { this.configuration = configuration; this.schemaManager = schemaManager; this.typeResolver = typeResolver; this.lookupManager = lookupManager; this.cubesEnvironment = cubesEnvironment; this.scopeFactory = scopeFactory; }
public AvailableCommand(ISchemaManager schemaManager) : base(CommandNames.Available, Resources.AvailableCommandDescription) { AddOption(CommandOptions.ServerOption()); Handler = CommandHandler.Create( (InvocationContext context, Uri server, CancellationToken token) => HandlerAsync(context, server, token)); Argument.AddValidator(symbol => RequiredOptionValidator.Validate(symbol, CommandOptions.ServerOption(), Resources.ServerRequiredValidation)); EnsureArg.IsNotNull(schemaManager); _schemaManager = schemaManager; }
public CurrentCommand(ISchemaManager schemaManager) : base(CommandNames.Current, Resources.CurrentCommandDescription) { AddOption(CommandOptions.ServerOption()); AddOption(CommandOptions.ConnectionStringOption()); Handler = CommandHandler.Create( (InvocationContext context, Uri server, string connectionString, CancellationToken token) => HandlerAsync(context, connectionString, server, token)); Argument.AddValidator(symbol => RequiredOptionValidator.Validate(symbol, CommandOptions.ConnectionStringOption(), Resources.ConnectionStringRequiredValidation)); Argument.AddValidator(symbol => RequiredOptionValidator.Validate(symbol, CommandOptions.ServerOption(), Resources.ServerRequiredValidation)); EnsureArg.IsNotNull(schemaManager, nameof(schemaManager)); _schemaManager = schemaManager; }
protected async Task ExecuteMigrationStep(IDbConnection connection, ISchemaManager targetManager, MigrationStep step, ObjectSchema targetSchema) { if (step.Action == MigrationAction.Alter) { throw new NotImplementedException($"Explicit alters are not supported"); } if (step.TargetType == MigrationTarget.Object) { if (step.Action == MigrationAction.Create) { await targetManager.CreateObject(connection, targetSchema); } else if (step.Action == MigrationAction.Drop) { await targetManager.DeleteObject(connection, step.TargetName); } } else if (step.TargetType == MigrationTarget.Column) { if (step.Action == MigrationAction.Create) { await targetManager.CreateColumn(connection, targetSchema.Name, targetSchema.Columns[step.TargetName]); } else if (step.Action == MigrationAction.Drop) { await targetManager.DeleteColumn(connection, targetSchema.Name, step.TargetName); } } else if (step.TargetType == MigrationTarget.Index) { if (step.Action == MigrationAction.Create) { await targetManager.CreateIndex(connection, targetSchema.Name, targetSchema.Indexes[step.TargetName]); } else if (step.Action == MigrationAction.Drop) { await targetManager.DeleteIndex(connection, targetSchema.Name, step.TargetName); } } else { throw new NotImplementedException($"No implementation for migration step"); } }
public FabricDatabase(string databaseRoot, IDatabaseHelper databaseHelper = null, IChangeSetHelper changeSetHelper = null, ISchemaManager schemaManager = null, IVersionHelper versionHelper = null) { DatabaseRoot = databaseRoot; if (Path.IsPathRooted(DatabaseRoot)) { FullDataBaseRoot = DatabaseRoot; } else { var relativePathRoot = AppDomain.CurrentDomain.BaseDirectory; var relativePath = Path.Combine(relativePathRoot, DatabaseRoot); FullDataBaseRoot = relativePath; } Resolver = new UnityContainer(); Resolver.RegisterInstance(this); SerializerSettings = new JsonSerializerSettings { Converters = new List <JsonConverter> { new DataPageSerializer(Resolver) }, Formatting = Formatting.Indented, ContractResolver = new CamelCasePropertyNamesContractResolver() }; Resolver.RegisterInstance(SerializerSettings); Resolver.RegisterInstanceOrDefault <IDatabaseHelper, FileSystemDatabaseHelper>(databaseHelper); Resolver.RegisterInstanceOrDefault <IChangeSetHelper, ChangeSetHelper>(changeSetHelper); Resolver.RegisterInstanceOrDefault <ISchemaManager, SchemaManager>(schemaManager); Resolver.RegisterInstanceOrDefault <IVersionHelper, VersionHelper>(versionHelper); }
public CachedSchemaManager(ISchemaCache schemaCache, ISchemaManager impl) { this.Impl = impl; this.SchemaCache = schemaCache; }
public DevJokeConfiguration(ISchemaManager schemaManager) : base(schemaManager) { }
public CategoryConfiguration(ISchemaManager schemaManager) : base(schemaManager) { }
public SQLServerDatabase(IConnectionManager connectionManager, IShardStrategy shardStrategy, ISchemaManager schemaManager) : base(connectionManager, shardStrategy, schemaManager) { }
public async Task <SchemaMigrationPlan> PlanMigration(IDbConnection connection, ISchemaManager targetManager, ObjectSchema targetSchema, MigrationOptions options) { options = options ?? new MigrationOptions(); // Whichever columns are mapped to SqlType, we let the manager decide the best choice foreach (var column in targetSchema.Columns.Values) { if (column.SqlType == null) { column.SqlType = targetManager.MapColumnType(column.DotnetType); } } var report = new SchemaMigrationPlan() { Target = targetSchema, }; report.Existing = await targetManager.GetSchema(connection, targetSchema.Name); if (report.Existing == null) { report.Steps.Add(new MigrationStep() { TargetName = targetSchema.Name, Action = MigrationAction.Create, TargetType = MigrationTarget.Object, }); return(report); } if (options.ForceDropRecreate) { options.AssertTableDeleteAllowed(targetSchema.Name); report.Steps.Add(new MigrationStep() { TargetName = targetSchema.Name, Action = MigrationAction.Drop, TargetType = MigrationTarget.Object, }); report.Steps.Add(new MigrationStep() { TargetName = targetSchema.Name, Action = MigrationAction.Create, TargetType = MigrationTarget.Object, }); return(report); } var allColumnNames = report.Target.Columns.Keys.Union(report.Existing.Columns.Keys); foreach (var column in allColumnNames) { var targetColumn = report.Target.Columns.ContainsKey(column) ? report.Target.Columns[column] : null; var existingColumn = report.Existing.Columns.ContainsKey(column) ? report.Existing.Columns[column] : null; PlanMigrateColumn(report, existingColumn, targetColumn, options); } var allIndexNames = report.Target.Indexes.Keys.Union(report.Existing.Indexes.Keys); foreach (var index in allIndexNames) { var targetIndex = report.Target.Columns.ContainsKey(index) ? report.Target.Columns[index] : null; var existingIndex = report.Existing.Columns.ContainsKey(index) ? report.Existing.Columns[index] : null; PlanMigrateIndex(report, existingIndex, targetIndex, options); } return(report); }
public async Task <SchemaMigrationPlan> ExecuteMigration(IDbConnection connection, ISchemaManager targetManager, SchemaMigrationPlan plan) { foreach (var step in plan.Steps) { await ExecuteMigrationStep(connection, targetManager, step, plan.Target); } return(plan); }
public static async Task PlanAndMigrate(this ISchemaMigrator migrator, IDbConnection connection, ISchemaManager targetManager, ObjectSchema targetSchema, MigrationOptions options) { var plan = await migrator.PlanMigration( connection : connection, targetManager : targetManager, targetSchema : targetSchema, options : options ); await migrator.ExecuteMigration( connection : connection, targetManager : targetManager, migrationPlan : plan ); }
internal SQLiteTable(SQLiteSession session, ISchemaManager schemaManager, object shardObject, object partitionObject, IShardStrategy shardStrategy) : base(session, schemaManager, shardObject, partitionObject, shardStrategy) { }
public AbstractDatabase(IConnectionManager connectionManager, IShardStrategy shardStrategy, ISchemaManager schemaManager) { AssertUtil.ArgumentNotNull(connectionManager, nameof(connectionManager)); this.ConnectionManager = connectionManager; this.ShardStrategy = shardStrategy; this.SchemaManager = schemaManager; }