diff options
| author | 2021-11-13 17:30:01 +0100 | |
|---|---|---|
| committer | 2021-11-13 17:30:01 +0100 | |
| commit | aee1932bd45aacf4790e1e3a307c01249558c99e (patch) | |
| tree | 5555ff46a7c7f0ea69fd2168d26476238a560433 /internal/db/bundb/migrations/README.md | |
| parent | move to ssb gofed fork (#298) (diff) | |
| download | gotosocial-aee1932bd45aacf4790e1e3a307c01249558c99e.tar.xz | |
First db migration (#297)
* store first db schema
* md linting *screams*
Diffstat (limited to 'internal/db/bundb/migrations/README.md')
| -rw-r--r-- | internal/db/bundb/migrations/README.md | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/internal/db/bundb/migrations/README.md b/internal/db/bundb/migrations/README.md index fee262936..06397b71b 100644 --- a/internal/db/bundb/migrations/README.md +++ b/internal/db/bundb/migrations/README.md @@ -28,29 +28,29 @@ As a template, take one of the existing migration files and modify it, or use th package migrations import ( - "context" + "context" - "github.com/uptrace/bun" + "github.com/uptrace/bun" ) func init() { - up := func(ctx context.Context, db *bun.DB) error { - return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { - // your logic here + up := func(ctx context.Context, db *bun.DB) error { + return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { + // your logic here return nil - }) - } + }) + } - down := func(ctx context.Context, db *bun.DB) error { - return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { - // your logic here + down := func(ctx context.Context, db *bun.DB) error { + return db.RunInTx(ctx, nil, func(ctx context.Context, tx bun.Tx) error { + // your logic here return nil - }) - } + }) + } - if err := Migrations.Register(up, down); err != nil { - panic(err) - } + if err := Migrations.Register(up, down); err != nil { + panic(err) + } } ``` @@ -61,7 +61,7 @@ Bun requires a very specific format: 14 digits, then letters or underscores. You can use the following bash command on your branch to generate a suitable migration filename. ```bash -echo "$(date --utc +%Y%m%H%M%S%N | head -c 14)_$(git rev-parse --abbrev-ref HEAD).go" +echo "$(date --utc +%Y%m%d%H%M%S | head -c 14)_$(git rev-parse --abbrev-ref HEAD).go" ``` ## Rules of thumb |
