Skip to content

Commit

Permalink
spelling out individual columns in partition migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremydmiller committed Oct 17, 2024
1 parent 20ee9a7 commit 6364b43
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Weasel.Postgresql/Tables/TableDelta.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;");
Expand All @@ -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;");
}
Expand Down

0 comments on commit 6364b43

Please sign in to comment.