public string[] CreateStatements(AlterColumnCommand command)
        {
            var builder = new StringBuilder();

            builder.AppendFormat("alter table {0} modify column {1} ",
                                 _dialect.QuoteForTableName(PrefixTableName(command.TableName)),
                                 _dialect.QuoteForColumnName(command.ColumnName));

            // type
            if (command.DbType != DbType.Object)
            {
                builder.Append(DefaultDataMigrationInterpreter.GetTypeName(_dialect, command.DbType, command.Length, command.Precision, command.Scale));
            }
            else
            {
                if (command.Length > 0 || command.Precision > 0 || command.Scale > 0)
                {
                    throw new OrchardException(T("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(DefaultDataMigrationInterpreter.ConvertToSqlValue(command.Default)).Append(" ");
            }

            return(new [] {
                builder.ToString()
            });
        }
        public string[] CreateStatements(AlterColumnCommand command)
        {
            var builder = new StringBuilder();

            builder.AppendFormat("alter table {0} alter column {1} ",
                                 _dialectLazy.Value.QuoteForTableName(PrefixTableName(command.TableName)),
                                 _dialectLazy.Value.QuoteForColumnName(command.ColumnName));
            var initLength = builder.Length;

            // type
            if (command.DbType != DbType.Object)
            {
                builder.AppendFormat("type {0}",
                                     DefaultDataMigrationInterpreter.GetTypeName(_dialectLazy.Value, command.DbType, command.Length, command.Precision, command.Scale));
            }
            else
            {
                if (command.Length > 0 || command.Precision > 0 || command.Scale > 0)
                {
                    throw new OrchardException(T("Error while executing data migration: you need to specify the field's type in order to change its properties"));
                }
            }

            // [default value]
            var builder2 = new StringBuilder();

            builder2.AppendFormat("alter table {0} alter column {1} ",
                                  _dialectLazy.Value.QuoteForTableName(PrefixTableName(command.TableName)),
                                  _dialectLazy.Value.QuoteForColumnName(command.ColumnName));
            var initLength2 = builder2.Length;

            if (command.Default != null)
            {
                builder2.Append(" set default ").Append(_dataMigrationInterpreter.ConvertToSqlValue(command.Default)).Append(" ");
            }

            // result
            var result = new List <string>();

            if (builder.Length > initLength)
            {
                result.Add(builder.ToString());
            }

            if (builder2.Length > initLength2)
            {
                result.Add(builder2.ToString());
            }

            return(result.ToArray());
        }
예제 #3
0
 public MySqlCommandInterpreter(DefaultDataMigrationInterpreter dataMigrationInterpreter, ITransactionManager transactionManager)
 {
     _transactionManager       = transactionManager;
     _dataMigrationInterpreter = dataMigrationInterpreter;
     T = NullLocalizer.Instance;
 }
예제 #4
0
 public MySqlCommandInterpreter(DefaultDataMigrationInterpreter dataMigrationInterpreter)
 {
     _dataMigrationInterpreter = dataMigrationInterpreter;
     T = NullLocalizer.Instance;
 }