Skip to content

Commit

Permalink
Merge branch 't4whitespace'
Browse files Browse the repository at this point in the history
  • Loading branch information
daniellee committed Nov 1, 2012
2 parents 497a764 + 44c16f8 commit eabe3b6
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions src/FluentMigrator.T4.Tests/IntialMigrationCode.tt
Expand Up @@ -68,16 +68,18 @@ foreach(Table tbl in from t in tables where !t.Ignore select t)
{
#>
//For <#=tbl.Name#>
Create.Table("<#=tbl.Name#>")<#if (string.IsNullOrEmpty(tbl.Schema) == false ){#>.InSchema("<#=tbl.Schema#>")<#}#>
<#
Create.Table("<#=tbl.Name#>")<#if (string.IsNullOrEmpty(tbl.Schema) == false ){#>.InSchema("<#=tbl.Schema#>")<#}#><#
var ColumnList = from c in tbl.Columns where !c.Ignore select c;
foreach(Column col in ColumnList)
{
#> .WithColumn("<#=col.Name#>").<#=generator.GetMigrationTypeFunctionForType(col.PropertyType,col.Size,col.Precision)
#>

.WithColumn("<#=col.Name#>").<#=generator.GetMigrationTypeFunctionForType(col.PropertyType,col.Size,col.Precision)
#><#if (col.IsPrimaryKey){#>.PrimaryKey()<#}#><#if (col.IsAutoIncrement){#>.Identity()<#}#><#if (col.IsNullable){#>.Nullable()<#} else {#>.NotNullable()<#}#><#if (col.DefaultValue != null){#>.WithDefaultValue(<#= generator.GetColumnDefaultValue(col) #>)<#}#>
<#
}
#> ;
#>;

<#
List<TableIndex> IndexList = tbl.Indexes;
foreach(TableIndex indx in IndexList)
Expand All @@ -87,12 +89,16 @@ foreach(TableIndex indx in IndexList)
<#
foreach(IndexColumn col in indx.IndexColumns)
{
#> .OnColumn("<#=col.Name#>")<#if (col.IsAsc){#>.Ascending()<#}else{#>.Descending()<#}#>
#>

.OnColumn("<#=col.Name#>")<#if (col.IsAsc){#>.Ascending()<#}else{#>.Descending()<#}#>
<#
}
#><#if (indx.IsUnique){
#> .WithOptions().Unique()<#}#>
;
#>

.WithOptions().Unique()<#}#>;

<#
}
#>
Expand All @@ -109,16 +115,17 @@ foreach(ForeignKey fkey in FKeyList)
{
#>
<# if(commentAlreadyWritten == false) { #> //Foreign Key List <# commentAlreadyWritten = true;} #>

Create.<#
if(!string.IsNullOrEmpty(fkey.Name))
{
#>ForeignKey("<#=fkey.Name#>")<#
} #>.FromTable("<#=tbl.Name#>").InSchema("<#=fkey.ForeignTableSchema#>").ForeignColumns(<#=Join(fkey.ForeignColumns)#>).ToTable("<#=fkey.PrimaryTable#>").InSchema("<#=fkey.PrimaryTableSchema#>").PrimaryColumns(<#=Join(fkey.PrimaryColumns)#>);
<#
<#
}
}
#>
}
}

public override void Down()
{
Expand All @@ -128,15 +135,14 @@ foreach(Table tbl in from t in tables where !t.Ignore select t)
List<ForeignKey> FKeyList = tbl.ForeignKeys;
foreach(ForeignKey fkey in FKeyList)
{
if(!string.IsNullOrEmpty(fkey.Name)){
#>
if(!string.IsNullOrEmpty(fkey.Name)){
#>
Delete.ForeignKey("<#=fkey.Name#>");
<#

<#
} else {
#>
Delete.ForeignKey().FromTable("<#=tbl.Name#>").InSchema("<#=fkey.ForeignTableSchema#>").ForeignColumns(<#=Join(fkey.ForeignColumns)#>).ToTable("<#=fkey.PrimaryTable#>")/*.InSchema("<#=fkey.PrimaryTableSchema#>")*/.PrimaryColumns(<#=Join(fkey.PrimaryColumns)#>);
<#
Delete.ForeignKey().FromTable("<#=tbl.Name#>").InSchema("<#=fkey.ForeignTableSchema#>").ForeignColumns(<#=Join(fkey.ForeignColumns)#>).ToTable("<#=fkey.PrimaryTable#>")/*.InSchema("<#=fkey.PrimaryTableSchema#>")*/.PrimaryColumns(<#=Join(fkey.PrimaryColumns)#>);
<#
}
}
}
Expand Down

0 comments on commit eabe3b6

Please sign in to comment.