(t *testing.T)
| 309 | } |
| 310 | |
| 311 | func TestComputeDiff_DropColumn_Destructive(t *testing.T) { |
| 312 | current := &sdata.DBInfo{ |
| 313 | Type: "postgres", |
| 314 | Tables: []sdata.DBTable{ |
| 315 | { |
| 316 | Name: "users", |
| 317 | Columns: []sdata.DBColumn{ |
| 318 | {Name: "id", Type: "bigint", PrimaryKey: true}, |
| 319 | {Name: "old_column", Type: "text"}, |
| 320 | }, |
| 321 | }, |
| 322 | }, |
| 323 | } |
| 324 | |
| 325 | expected := &sdata.DBInfo{ |
| 326 | Type: "postgres", |
| 327 | Tables: []sdata.DBTable{ |
| 328 | { |
| 329 | Name: "users", |
| 330 | Columns: []sdata.DBColumn{ |
| 331 | {Name: "id", Type: "bigint", PrimaryKey: true}, |
| 332 | }, |
| 333 | }, |
| 334 | }, |
| 335 | } |
| 336 | |
| 337 | // With destructive flag |
| 338 | ops := computeDiff(current, expected, DiffOptions{Destructive: true}) |
| 339 | |
| 340 | found := false |
| 341 | for _, op := range ops { |
| 342 | if op.Type == "drop_column" && op.Column == "old_column" { |
| 343 | found = true |
| 344 | if !op.Danger { |
| 345 | t.Error("drop_column operation should be marked as dangerous") |
| 346 | } |
| 347 | } |
| 348 | } |
| 349 | |
| 350 | if !found { |
| 351 | t.Error("expected drop_column operation when destructive is true") |
| 352 | } |
| 353 | } |
| 354 | |
| 355 | func TestComputeDiff_DropTable_Destructive(t *testing.T) { |
| 356 | current := &sdata.DBInfo{ |
nothing calls this directly
no test coverage detected