# migration tests

FEATURE: migration 10 (delete + add field) force-migration
# testing that we don't over-optimize our rename algorithm
# we are adding a field with a different type
background:
 configure loadFKs = true
thenType: struct

# -- start chain ---
---
title: migration10a
chainNextTest:true
useSafeMigrationPolicy:false
cleanTables:Customer,Customer__BAK,DELIA_SCHEMA_VERSION
given:
 type Customer struct {id int unique serial, wid int } end

when:
  insert Customer { wid:33}
  let x = Customer[1]
then:
value:a:Customer {
 vid:1
 vwid:33
}

---
title: migration10a.1 - rename field TODO:migration should check and halt when this occurs
#this fails because we added mandatory field wid2 but didn't update previous records
useSafeMigrationPolicy:false
chainNextTest:true
given:
 type Customer struct {id int unique serial, wid2 long } end

when:
  insert Customer { wid2:34}
  let x = Customer[1]
then:
ERROR: NODATA

---
title: migration10a.2 - new record is ok
useSafeMigrationPolicy:false
given:
 type Customer struct {id int unique serial, wid2 long } end

when:
  let x = Customer[2]
then:
value:a:Customer {
 vid:2
 vwid2:34
}

