<%
'=======================================================================================================================
' MIGRATION: add_purple_ballot_list_count_and_blue_nonprofit_options
'=======================================================================================================================
' This migration was auto-generated. Add your migration logic below.
'
' The migration object provides these helper methods:
'   - migration.ExecuteSQL(sql)                              - Execute raw SQL
'   - migration.CreateTable(name, columns)                   - Create a table
'   - migration.DropTable(name)                              - Drop a table
'   - migration.AddColumn(table, column, type)               - Add a column
'   - migration.DropColumn(table, column)                    - Drop a column
'   - migration.CreateIndex(name, table, columns)            - Create an index
'   - migration.DropIndex(name, table)                       - Drop an index
'
' For complex operations, use migration.DB to access the database directly:
'   migration.DB.Execute "INSERT INTO users (name) VALUES (?)", Array("John")
'

'-----------------------------------------------------------------------------------------------------------------------
' UP - Apply the migration
'-----------------------------------------------------------------------------------------------------------------------
Sub Migration_Up(migration)
    ' Fields added/changed by the revised order-form PDFs (docs/lucid/*"(2).pdf").

    ' Purple Ballot Envelope section - new "permanent ballot list" count, asked
    ' alongside PurpleEnvelopeStock/PurplePrintOption.
    migration.AddColumn "OrderDetails", "PurplePermanentBallotListCount", "INTEGER"

    ' Blue AV Envelope section - BlueHasNonprofitStatus gained a third "Unsure" choice and
    ' is now asked for both permit-ownership branches, so it can no longer be YESNO.
    ' Existing YESNO test data converts to "-1"/"0" text under this type change - there's no
    ' real order data yet, so that's acceptable here.
    migration.ExecuteSQL "ALTER TABLE OrderDetails ALTER COLUMN BlueHasNonprofitStatus VARCHAR(20)"
End Sub

'-----------------------------------------------------------------------------------------------------------------------
' DOWN - Rollback the migration
'-----------------------------------------------------------------------------------------------------------------------
Sub Migration_Down(migration)
    migration.ExecuteSQL "ALTER TABLE OrderDetails ALTER COLUMN BlueHasNonprofitStatus YESNO"
    migration.DropColumn "OrderDetails", "PurplePermanentBallotListCount"
End Sub
%>
