/// <summary>
        /// Applies a convention to a FluentMigrator.Expressions.IForeignKeyExpression
        /// </summary>
        /// <param name="expression">The expression this convention should be applied to</param>
        /// <returns>The same or a new expression. The underlying type must stay the same</returns>
        public IForeignKeyExpression Apply(IForeignKeyExpression expression)
        {
            if (string.IsNullOrEmpty(expression.ForeignKey.Name))
            {
                expression.ForeignKey.Name = GetForeignKeyName(expression.ForeignKey);
            }

            return(expression);
        }
Example #2
0
        public IForeignKeyExpression Apply(IForeignKeyExpression expression)
        {
            expression.ForeignKey.PrimaryColumns = expression.ForeignKey.PrimaryColumns.Select(c => c.ToSnakeCase()).ToList();
            expression.ForeignKey.ForeignColumns = expression.ForeignKey.ForeignColumns.Select(c => c.ToSnakeCase()).ToList();
            expression.ForeignKey.Name           = expression.ForeignKey.Name ??
                                                   $"FK_{expression.ForeignKey.ForeignTable}_{expression.ForeignKey.ForeignColumns.First()}_{expression.ForeignKey.PrimaryTable}_{expression.ForeignKey.PrimaryColumns.First()}";

            return(expression);
        }
Example #3
0
 /// <inheritdoc />
 public IForeignKeyExpression Apply(IForeignKeyExpression expression)
 {
     expression.ForeignKey.ForeignTableSchema = GetSchemaName(expression.ForeignKey.ForeignTableSchema);
     expression.ForeignKey.PrimaryTableSchema = GetSchemaName(expression.ForeignKey.PrimaryTableSchema);
     return(expression);
 }