diff --git a/providers/db.go b/providers/db.go index 39837f9..d8a396c 100644 --- a/providers/db.go +++ b/providers/db.go @@ -168,7 +168,7 @@ func (c *DotDB) rollback() error { // - includeIds: A list of specific migration IDs to apply. If provided other ids are skipped. // // Returns the number of migrations applied, and returns an error on these conditions: -// - Rexex expr does not have a submatch +// - Regex expr does not have a submatch // - Fails to list files in the dir // - The submatch expression is not convertible to a uint64 // - The migration file could not be read diff --git a/test/migrations/manual.1.sql b/test/migrations/manual.1.sql new file mode 100644 index 0000000..94b5359 --- /dev/null +++ b/test/migrations/manual.1.sql @@ -0,0 +1 @@ +CREATE TABLE manual(id); diff --git a/test/migrations/manual.2.sql b/test/migrations/manual.2.sql new file mode 100644 index 0000000..691bef1 --- /dev/null +++ b/test/migrations/manual.2.sql @@ -0,0 +1 @@ +DROP TABLE manual; diff --git a/test/templates/db/index.html b/test/templates/db/.init.html similarity index 75% rename from test/templates/db/index.html rename to test/templates/db/.init.html index b31de58..df4b387 100644 --- a/test/templates/db/index.html +++ b/test/templates/db/.init.html @@ -1,5 +1,5 @@ - - + +{{define "INIT db"}}
{{.DB.Migrate .Migrations `^schema\.(\d+)\.sql$` (.DB.QueryVal `PRAGMA user_version;`)}} migrations applied.
-Current user_version: {{.DB.QueryVal `PRAGMA user_version`}}
+{{end}} diff --git a/test/templates/db/manual.html b/test/templates/db/manual.html new file mode 100644 index 0000000..9886ce1 --- /dev/null +++ b/test/templates/db/manual.html @@ -0,0 +1,29 @@ + + + +{{$RE := `^manual\.(\d+)\.sql$`}} +Run a manual migration:
+{{range .Migrations.List "."}} +{{$id := atoi (regexReplaceAll $RE .Name "$1")}} +{{if eq $id 0}}{{continue}}{{end}} + +{{end}} + +Results:
+{{$result.Error}}
+{{end}}
+