You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 99b2b6d
Browse filesBrowse the repository at this point in the historyBrowse files
<p><code>import "github.com/Deufel/migrate"</code></p><h2id="overview">Overview</h2><p>Package migrate runs numbered SQL migrations against a SQLite database —
@@ -32,8 +32,8 @@
32
32
<p>A migration is a file named NNNN-description.sql (a four-digit version,
33
33
a kebab description). Files run in version order; each is applied at
34
34
most once; the record lives in one table (sys_migration by default):
35
-
<pre>version · name · sha256 · applied_at
36
-
</pre>
35
+
<divclass="column" style="--gap: 0;"><pre>version · name · sha256 · applied_at
36
+
</pre></div>
37
37
<p>Rules, in the order the runner checks them:
38
38
<ol>
39
39
<li>every applied version must still have its file, byte-identical
@@ -52,31 +52,31 @@
52
52
<p>A structure change is written as SQL: create the new table, INSERT …
53
53
SELECT, drop the old, rename, recreate the indexes. The declaration
54
54
changes and the data follows in the same file.
55
-
<h2id="functions">Functions</h2><h3id="baseline">Baseline</h3><pre><codeclass="go">func Baseline(ctx context.Context, db *sql.DB, o Options, version int) error</code></pre><p>Baseline stamps every file up to and including version as applied
55
+
<h2id="functions">Functions</h2><h3id="baseline">Baseline</h3><divclass="column" style="--gap: 0;"><pre><codeclass="go">func Baseline(ctx context.Context, db *sql.DB, o Options, version int) error</code></pre></div><p>Baseline stamps every file up to and including version as applied
56
56
WITHOUT running it — for a database that already carries the schema
57
57
the baseline file describes. Refused when anything is recorded already.
58
-
<h3id="next">Next</h3><pre><codeclass="go">func Next(fsys fs.FS, description string) (string, error)</code></pre><p>Next answers the file name a new migration should take.
<h3id="next">Next</h3><divclass="column" style="--gap: 0;"><pre><codeclass="go">func Next(fsys fs.FS, description string) (string, error)</code></pre></div><p>Next answers the file name a new migration should take.
Name string // the description part of the file name
68
68
File string
69
69
SHA string // sha256 of the file's bytes
70
70
AppliedAt string // RFC3339, "" when pending
71
-
}</code></pre><p>Step is one migration file, applied or pending.
72
-
<h3id="load">Load</h3><pre><codeclass="go">func Load(fsys fs.FS) ([]Step, error)</code></pre><p>Load reads and orders the files. A name off the pattern, a duplicate
71
+
}</code></pre></div><p>Step is one migration file, applied or pending.
72
+
<h3id="load">Load</h3><divclass="column" style="--gap: 0;"><pre><codeclass="go">func Load(fsys fs.FS) ([]Step, error)</code></pre></div><p>Load reads and orders the files. A name off the pattern, a duplicate
73
73
version or an empty file is an error.
74
-
<h3id="run">Run</h3><pre><codeclass="go">func Run(ctx context.Context, db *sql.DB, o Options) ([]Step, error)</code></pre><p>Run applies every pending file in order and answers the ones applied.
74
+
<h3id="run">Run</h3><divclass="column" style="--gap: 0;"><pre><codeclass="go">func Run(ctx context.Context, db *sql.DB, o Options) ([]Step, error)</code></pre></div><p>Run applies every pending file in order and answers the ones applied.
75
75
The first error stops the run with the failed file rolled back.
76
-
<h3id="status">Status</h3><pre><codeclass="go">func Status(ctx context.Context, db *sql.DB, o Options) (applied, pending []Step, err error)</code></pre><p>Status answers what is applied and what is pending, after verifying
76
+
<h3id="status">Status</h3><divclass="column" style="--gap: 0;"><pre><codeclass="go">func Status(ctx context.Context, db *sql.DB, o Options) (applied, pending []Step, err error)</code></pre></div><p>Status answers what is applied and what is pending, after verifying
77
77
rules 1 and 2. The applied steps carry the file's name and hash from
78
78
the record; the pending ones from the file.
79
-
<h2id="examples">Examples</h2><h3id="examplebaseline">Baseline</h3><pre><codeclass="go">package main
79
+
<h2id="examples">Examples</h2><h3id="examplebaseline">Baseline</h3><divclass="column" style="--gap: 0;"><pre><codeclass="go">package main
0 commit comments