<%
'=======================================================================================================================
' MIGRATION: create_order_details_table
'=======================================================================================================================
' 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)
    ' One row per Order (1:1 sidecar) holding the answers from the SurveyJS election-materials
    ' order form. Field names are prefixed by the survey section they belong to.
    migration.CreateTable "OrderDetails", _
        "OrderDetailID COUNTER PRIMARY KEY, " & _
        "OrderID LONG NOT NULL, " & _
        _
        "ContactName VARCHAR(255), " & _
        "Municipality VARCHAR(255), " & _
        "Phone VARCHAR(50), " & _
        _
        "PurpleWantsQuote YESNO, " & _
        "PurplePrintOption VARCHAR(50), " & _
        "PurpleEnvelopeStock VARCHAR(50), " & _
        "PurpleEnvelopeProvider VARCHAR(255), " & _
        "PurpleWantsBlueEnvelopes YESNO, " & _
        "PurplePrintStyle VARCHAR(50), " & _
        "PurpleColorCodingBy VARCHAR(50), " & _
        "PurplePrecinctCount INTEGER, " & _
        "PurpleTrackMIBallot YESNO, " & _
        "PurpleExtraEnvelopeQty INTEGER, " & _
        "PurpleDeliveryDate DATETIME, " & _
        _
        "BlueWantsQuote YESNO, " & _
        "BlueEnvelopeProvider VARCHAR(50), " & _
        "BluePrintPermit YESNO, " & _
        "BluePermitNumber VARCHAR(50), " & _
        "BluePermitCity VARCHAR(255), " & _
        "BluePermitClass VARCHAR(10), " & _
        "BluePrintReturnAddress YESNO, " & _
        "BlueDeliveryDate DATETIME, " & _
        _
        "MailingWantsService YESNO, " & _
        "MailingPostageOption VARCHAR(50), " & _
        "MailingHasNonprofitStatus VARCHAR(20), " & _
        "MailingWantsSorting YESNO, " & _
        "MailingPickupDate DATETIME, " & _
        _
        "SecrecySleevesQty INTEGER, " & _
        "IVotedStickerRolls INTEGER, " & _
        "FutureVoterStickerRolls INTEGER, " & _
        _
        "SubmittedAt DATETIME NOT NULL"

    migration.CreateIndex "IX_OrderDetails_OrderID", "OrderDetails", "OrderID"
End Sub

'-----------------------------------------------------------------------------------------------------------------------
' DOWN - Rollback the migration
'-----------------------------------------------------------------------------------------------------------------------
Sub Migration_Down(migration)
    migration.DropIndex "IX_OrderDetails_OrderID", "OrderDetails"
    migration.DropTable "OrderDetails"
End Sub
%>
