%
Option Explicit
Sub put(v)
    response.write v & "
"
End Sub
Sub put_
    put ""
End Sub
Sub put_error(s)
    put "" & s & ""
End Sub
%>
<%
'Have to initialize Migrations_Class before including any actual migrations, because they each automatically append themselves to the Migrations class for convenience.
'TODO: This can be refactored by not having the individual migration files auto-add themselves, but then this file must manually add each one using a slightly dIfferent
'            naming convention, i.e. given include file 01_Create_Users.asp the command would be Migrations.Add "Migration_01_Create_Users" or such. At least this way is automated.
'Migrations.Initialize "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\webdata - Copy.mdb;"
 Migrations.Initialize "Provider=SQLOLEDB;Server=danielsubuntu,15789;Database=tracking;UID=sa;PWD=SunBrightShine!;"
Migrations.Tracing = false
%>
<%
Sub HandleMigration
    putl "Starting Version: " & Migrations.Version & ""
    If Request.Form("mode") = "direct" then
        If Request.Form("direction") = "Up" then
            If Len(Request.Form("to")) > 0 then
                Migrations.MigrateUpTo(Request.Form("to"))
            Else
                Migrations.MigrateUp
            End If
        ElseIf Request.Form("direction") = "Down" then
            If Len(Request.Form("to")) > 0 then
                Migrations.MigrateDownTo(Request.Form("to"))
            Else
                Migrations.MigrateDown
            End If
        End If
    ElseIf Request.Form("mode") = "up_one" then
        Migrations.MigrateUpBy 1
    ElseIf Request.Form("mode") = "down_one" then
        Migrations.MigrateDownBy 1
    End If
    putl "Final Version: " & Migrations.Version & ""
End Sub
Sub ShowForm
%>