diff --git a/src/Weasel.Postgresql/Tables/TableDelta.cs b/src/Weasel.Postgresql/Tables/TableDelta.cs index 31704c2..baa4aa9 100644 --- a/src/Weasel.Postgresql/Tables/TableDelta.cs +++ b/src/Weasel.Postgresql/Tables/TableDelta.cs @@ -136,6 +136,8 @@ public override void WriteUpdate(Migrator rules, TextWriter writer) } else if (this.PartitionDelta == PartitionDelta.Rebuild) { + var columns = Expected.Columns.Select(x => x.Name).Join(", "); + var tempName = new DbObjectName(Expected.Identifier.Schema, Expected.Identifier.Name + "_temp"); writer.WriteLine($"create table {tempName} as select * from {Expected.Identifier};"); writer.WriteLine($"drop table {Expected.Identifier} cascade;"); @@ -144,7 +146,7 @@ public override void WriteUpdate(Migrator rules, TextWriter writer) writer.WriteLine(); - writer.WriteLine($"insert into {Expected.Identifier} select * from {tempName};"); + writer.WriteLine($"insert into {Expected.Identifier}({columns}) select {columns} from {tempName};"); writer.WriteLine($"drop table {tempName} cascade;"); }