<%
'=======================================================================================================================
' MIGRATION: revise_order_details_columns
'=======================================================================================================================
' 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 by the revised order-form PDFs (docs/lucid/*"(1).pdf"). Additive only -
    ' columns made obsolete by the revision (BluePermitClass, BluePrintReturnAddress,
    ' BlueDeliveryDate, MailingWantsSorting, PurpleEnvelopeProvider) are left in place rather
    ' than dropped, since the table already has real test data in it.

    ' Purple Ballot Envelope section
    migration.AddColumn "OrderDetails", "PurpleColorNames", "VARCHAR(255)"
    migration.AddColumn "OrderDetails", "PurpleBlueProvider", "VARCHAR(50)"
    migration.AddColumn "OrderDetails", "PurpleBlueProviderOther", "VARCHAR(255)"

    ' Blue AV Envelope section - new permit-ownership/nonprofit-status sub-flow
    migration.AddColumn "OrderDetails", "BluePermitOwnership", "VARCHAR(20)"
    migration.AddColumn "OrderDetails", "BlueHasNonprofitStatus", "YESNO"
    migration.AddColumn "OrderDetails", "BlueNonprofitAuthCode", "VARCHAR(100)"

    ' Ballot Mailing Service section
    migration.AddColumn "OrderDetails", "MailingEstimatedQuantity", "INTEGER"

    ' General - end-of-form special requests
    migration.AddColumn "OrderDetails", "SpecialRequests", "MEMO"
End Sub

'-----------------------------------------------------------------------------------------------------------------------
' DOWN - Rollback the migration
'-----------------------------------------------------------------------------------------------------------------------
Sub Migration_Down(migration)
    migration.DropColumn "OrderDetails", "PurpleColorNames"
    migration.DropColumn "OrderDetails", "PurpleBlueProvider"
    migration.DropColumn "OrderDetails", "PurpleBlueProviderOther"
    migration.DropColumn "OrderDetails", "BluePermitOwnership"
    migration.DropColumn "OrderDetails", "BlueHasNonprofitStatus"
    migration.DropColumn "OrderDetails", "BlueNonprofitAuthCode"
    migration.DropColumn "OrderDetails", "MailingEstimatedQuantity"
    migration.DropColumn "OrderDetails", "SpecialRequests"
End Sub
%>
