protected override void Generate(DropIndexOperation dropIndexOperation, IndentedTextWriter writer) { var isReadonly = ReadonlyEntities.Contains(dropIndexOperation.Table); if (!isReadonly) { base.Generate(dropIndexOperation, writer); } }
/// <summary> /// Gets an operation to drop the associated index on the foreign key column(s). /// </summary> /// <returns>An operation to drop the index.</returns> public virtual DropIndexOperation CreateDropIndexOperation() { var dropIndexOperation = new DropIndexOperation(_inverse.CreateCreateIndexOperation()) { Table = DependentTable }; DependentColumns.Each(c => dropIndexOperation.Columns.Add(c)); return dropIndexOperation; }
/// <inheritdoc /> protected override void Generate(DropIndexOperation dropIndexOperation) { using (var writer = Writer()) { writer.Write("DROP INDEX "); writer.Write(Name(dropIndexOperation.Table)); writer.Write("."); writer.Write(Quote(dropIndexOperation.Name)); Statement(writer); } }
/// <summary> /// Gets an operation to drop the associated index on the foreign key column(s). /// </summary> /// <returns> An operation to drop the index. </returns> public virtual DropIndexOperation CreateDropIndexOperation() { var dropIndexOperation = new DropIndexOperation(_inverse.CreateCreateIndexOperation()) { Table = DependentTable, IsSystem = IsSystem }; DependentColumns.Each(c => dropIndexOperation.Columns.Add(c)); return(dropIndexOperation); }
public void Can_get_and_set_properties() { var dropIndexOperation = new DropIndexOperation { Table = "T", Name = "Custom" }; dropIndexOperation.Columns.Add("foo"); dropIndexOperation.Columns.Add("bar"); Assert.Equal("T", dropIndexOperation.Table); Assert.Equal("foo", dropIndexOperation.Columns.First()); Assert.Equal("bar", dropIndexOperation.Columns.Last()); Assert.Equal("Custom", dropIndexOperation.Name); Assert.Equal("IX_foo_bar", dropIndexOperation.DefaultName); Assert.False(dropIndexOperation.HasDefaultName); }
/// <summary> /// Generates SQL for a <see cref="DropIndexOperation" />. /// Generated SQL should be added using the Statement method. /// </summary> /// <param name="dropIndexOperation"> The operation to produce SQL for. </param> protected virtual void Generate(DropIndexOperation dropIndexOperation) { Check.NotNull(dropIndexOperation, "dropIndexOperation"); using (var writer = Writer()) { writer.Write("IF EXISTS (SELECT name FROM sys.indexes WHERE name = N'"); writer.Write(Escape(dropIndexOperation.Name)); writer.Write("' AND object_id = object_id(N'"); writer.Write(Escape(Name(dropIndexOperation.Table))); writer.WriteLine("', N'U'))"); writer.Indent++; writer.Write("DROP INDEX "); writer.Write(Quote(dropIndexOperation.Name)); writer.Write(" ON "); writer.Write(Name(dropIndexOperation.Table)); writer.Indent--; Statement(writer); } }
/// <summary> /// Generates code to perform a <see cref="DropIndexOperation" />. /// </summary> /// <param name="dropIndexOperation"> The operation to generate code for. </param> /// <param name="writer"> Text writer to add the generated code to. </param> protected virtual void Generate(DropIndexOperation dropIndexOperation, IndentedTextWriter writer) { Check.NotNull(dropIndexOperation, "dropIndexOperation"); Check.NotNull(writer, "writer"); writer.Write("DropIndex("); writer.Write(Quote(dropIndexOperation.Table)); writer.Write(", "); if (!dropIndexOperation.HasDefaultName) { writer.Write(Quote(dropIndexOperation.Name)); } else { writer.Write("New String() { "); writer.Write(dropIndexOperation.Columns.Join(Quote)); writer.Write(" }"); } writer.WriteLine(")"); }
public void Generate_can_output_statement_to_drop_index_operation() { var migrationSqlGenerator = new SqlServerMigrationSqlGenerator(); var operation = new DropIndexOperation { Name = "IX_na'me", Table = "sch'ema.Ta'ble" }; var sql = migrationSqlGenerator.Generate(new[] { operation }, SqlProviderManifest.TokenAzure11) .Join(s => s.Sql, Environment.NewLine); const string expectedSql = @"IF EXISTS (SELECT name FROM sys.indexes WHERE name = N'IX_na''me' AND object_id = object_id(N'[sch''ema].[Ta''ble]', N'U')) DROP INDEX [IX_na'me] ON [sch'ema].[Ta'ble]"; Assert.Equal(expectedSql, sql); }
private void Convert(DropIndexOperation dropIndexOperation) { StringBuilder sql = new StringBuilder(); sql.Append("DROP INDEX IF EXISTS "); sql.Append(GetSchemaNameFromFullTableName(dropIndexOperation.Table)); sql.Append(".\""); sql.Append(GetTableNameFromFullTableName(dropIndexOperation.Table) + "_" + dropIndexOperation.Name); sql.Append('"'); AddStatment(sql); }
public void GenerateCanOutputDropIndexOperation() { var migrationSqlGenerator = new PostgreSqlMigrationSqlGenerator(); var dropIndexOperation = new DropIndexOperation { Table = "dbo.Custumers" }; dropIndexOperation.Columns.Add("Id"); var sql = migrationSqlGenerator.Generate(new[] { dropIndexOperation }, "9.2").Join(s => s.Sql, Environment.NewLine); Assert.True(sql.Contains("DROP INDEX \"dbo\".\"IX_dbo.Custumers_Id\"")); }
/// <summary> /// Generates code to perform a <see cref = "DropIndexOperation" />. /// </summary> /// <param name = "dropIndexOperation">The operation to generate code for.</param> /// <param name = "writer">Text writer to add the generated code to.</param> protected virtual void Generate(DropIndexOperation dropIndexOperation, IndentedTextWriter writer) { Contract.Requires(dropIndexOperation != null); Contract.Requires(writer != null); writer.Write("DropIndex("); writer.Write(Quote(dropIndexOperation.Table)); writer.Write(", "); if (!dropIndexOperation.HasDefaultName) { writer.Write(Quote(dropIndexOperation.Name)); } else { writer.Write("New String() { "); writer.Write(dropIndexOperation.Columns.Join(Quote)); writer.Write(" }"); } writer.WriteLine(")"); }
/// <summary> /// Generates SQL for a <see cref = "DropIndexOperation" />. /// Generated SQL should be added using the Statement method. /// </summary> /// <param name = "dropIndexOperation">The operation to produce SQL for.</param> protected virtual void Generate(DropIndexOperation dropIndexOperation) { Contract.Requires(dropIndexOperation != null); using (var writer = Writer()) { writer.Write("DROP INDEX "); writer.Write(Quote(dropIndexOperation.Name)); writer.Write(" ON "); writer.Write(Name(dropIndexOperation.Table)); Statement(writer); } }
/// <summary> /// Generates SQL for a <see cref="DropIndexOperation" />. /// Generated SQL should be added using the Statement method. /// </summary> /// <param name="dropIndexOperation"> The operation to produce SQL for. </param> protected virtual void Generate(DropIndexOperation dropIndexOperation) { Check.NotNull(dropIndexOperation, "dropIndexOperation"); using (var writer = Writer()) { writer.Write("DROP INDEX "); writer.Write(Name(dropIndexOperation.Table)); writer.Write("."); writer.Write(Quote(dropIndexOperation.Name)); Statement(writer); } }
protected virtual MigrationStatement Generate(DropIndexOperation op) { return new MigrationStatement() { Sql = string.Format("alter table `{0}` drop index `{1}`", op.Table, op.Name) }; }
protected override void Generate(DropIndexOperation dropIndexOperation) { base.Generate(dropIndexOperation); }
protected override void Generate(DropIndexOperation dio) { if (dio.HasDefaultName) dio.Name = GetIndexName(dio.Table, dio.Columns, null); base.Generate(dio); }
/// <summary> /// Gera SQL para uma operação <see cref="DropIndexOperation" />. /// </summary> /// <param name="opeDropIndex"> The operation to produce SQL for. </param> protected virtual void Generate(DropIndexOperation opeDropIndex) { using (var ltextWriter = TextWriter()) { ltextWriter.Write("DROP INDEX "); ltextWriter.Write(opeDropIndex.Name); ComandoSQL(ltextWriter); } }
protected override void Generate(DropIndexOperation dropIndexOperation) { Contract.Requires(dropIndexOperation != null); using (var writer = Writer()) { writer.Write("DROP INDEX "); writer.Write(IndexName(dropIndexOperation, true)); Statement(writer); } }
protected override void Generate(DropIndexOperation dropIndexOperation, IndentedTextWriter writer) { dropIndexOperation.Table = TrimSchemaPrefix(dropIndexOperation.Table); base.Generate(dropIndexOperation, writer); }
protected virtual IEnumerable<MigrationStatement> Generate(DropIndexOperation operation) { using (var writer = SqlWriter()) { writer.Write("DROP INDEX "); writer.Write(Quote(CreateItemName(operation.Name))); yield return Statement(writer); } }
protected virtual IEnumerable<MigrationStatement> Generate(DropIndexOperation operation) { using (var writer = SqlWriter()) { writer.Write("DROP INDEX "); writer.Write(Quote(string.Format("{0}.{1}_{2}", SchemaName(operation.Table), FixName(ObjectName(operation.Table)), FixName(operation.Name)))); yield return Statement(writer); } }
protected override MigrationStatement Generate(DropIndexOperation dropIndexOperation) { dropIndexOperation.Name = StripDbo(dropIndexOperation.Name); dropIndexOperation.Table = StripDbo(dropIndexOperation.Table); return base.Generate(dropIndexOperation); }