public void Visit(StringBuilder builder, AlterColumnCommand command) { if (ExecuteCustomInterpreter(command)) { return; } builder.AppendFormat("alter table {0} alter column {1} ", _dialect.QuoteForTableName(command.TableName), _dialect.QuoteForColumnName(command.ColumnName)); // type if (command.DbType != DbType.Object) { builder.Append(GetTypeName(command.DbType, command.Length, command.Precision, command.Scale)); } else { if (command.Length > 0 || command.Precision > 0 || command.Scale > 0) { throw new MonahrqCoreException("Error while executing data migration: you need to specify the field's type in order to change its properties"); } } // [default value] if (command.Default != null) { builder.Append(" set default ").Append(ConvertToSqlValue(command.Default)).Append(Space); } SqlStatementList.Add(builder.ToString()); }
public void Visit(StringBuilder builder, DropIndexCommand command) { if (ExecuteCustomInterpreter(command)) { return; } builder.AppendFormat("drop index {0} ON {1}", _dialect.QuoteForColumnName(command.IndexName), _dialect.QuoteForTableName(command.TableName)); SqlStatementList.Add(builder.ToString()); }
public void Visit(StringBuilder builder, AddColumnCommand command) { if (ExecuteCustomInterpreter(command)) { return; } builder.AppendFormat("alter table {0} add ", _dialect.QuoteForTableName(command.TableName)); Visit(builder, (CreateColumnCommand)command); SqlStatementList.Add(builder.ToString()); }
public override void Visit(DropForeignKeyCommand command) { if (ExecuteCustomInterpreter(command)) { return; } var builder = new StringBuilder(); builder.AppendFormat("alter table {0} drop constraint {1}", _dialect.QuoteForTableName(command.SrcTable), command.Name); SqlStatementList.Add(builder.ToString()); RunPendingStatements(); }
public void Visit(StringBuilder builder, AddIndexCommand command) { if (ExecuteCustomInterpreter(command)) { return; } builder.AppendFormat("create index {1} on {0} ({2}) ", _dialect.QuoteForTableName(command.TableName), _dialect.QuoteForColumnName(command.IndexName), String.Join(", ", command.ColumnNames)); SqlStatementList.Add(builder.ToString()); }
public override void Visit(DropTableCommand command) { if (ExecuteCustomInterpreter(command)) { return; } var builder = new StringBuilder(); builder.Append(_dialect.GetDropTableString(command.Name)); SqlStatementList.Add(builder.ToString()); RunPendingStatements(); }
public override void Visit(SqlStatementCommand command) { if (command.Providers.Count != 0 && !command.Providers.Contains(ConfigurationService.ConnectionSettings.ProviderName)) { return; } if (ExecuteCustomInterpreter(command)) { return; } SqlStatementList.Add(command.Sql); RunPendingStatements(); }
public override void Visit(CreateTableCommand command) { if (ExecuteCustomInterpreter(command)) { return; } var builder = new StringBuilder(); builder.Append(_dialect.CreateMultisetTableString) .Append(' ') .Append(_dialect.QuoteForTableName(command.Name)) .Append(" ("); var appendComma = false; foreach (var createColumn in command.TableCommands.OfType <CreateColumnCommand>()) { if (appendComma) { builder.Append(", "); } appendComma = true; Visit(builder, createColumn); } var primaryKeys = command.TableCommands.OfType <CreateColumnCommand>().Where(ccc => ccc.IsPrimaryKey).Select(ccc => ccc.ColumnName); if (primaryKeys.Any()) { if (appendComma) { builder.Append(", "); } builder.Append(_dialect.PrimaryKeyString) .Append(" ( ") .Append(String.Join(", ", primaryKeys.ToArray())) .Append(" )"); } builder.Append(" )"); SqlStatementList.Add(builder.ToString()); RunPendingStatements(); }
public override void Visit(CreateForeignKeyCommand command) { if (ExecuteCustomInterpreter(command)) { return; } var builder = new StringBuilder(); builder.Append("alter table ") .Append(_dialect.QuoteForTableName(command.SrcTable)); builder.Append(_dialect.GetAddForeignKeyConstraintString(command.Name, command.SrcColumns, _dialect.QuoteForTableName(command.DestTable), command.DestColumns, false)); SqlStatementList.Add(builder.ToString()); RunPendingStatements(); }