Switch to migrator's new "base" versioning.

This commit is contained in:
Benjamin A. Shelton 2026-10-28 22:50:01 -06:00
commit e53f21e814
Signed by: zancarius
GPG key ID: 8BD42DBD6C337E01
3 changed files with 26 additions and 6 deletions

View file

@ -4,11 +4,9 @@ import (
"context"
"fmt"
"code.destrealm.net/zancarius/justusbot/internal/app"
"code.destrealm.net/zancarius/justusbot/internal/models"
"code.destrealm.net/zancarius/justusbot/internal/settings"
"github.com/urfave/cli/v3"
"go.destrealm.net/embedder"
"go.destrealm.net/errors"
"go.destrealm.net/logging/v3"
"go.destrealm.net/migratory"
@ -35,11 +33,13 @@ func (inst *installer) DoInstall(ctx context.Context, cmd *cli.Command) error {
//
// This code is being added here to support embedded migrations in the
// future.
efs := embedder.NewEmbedderVFS(app.LoadBucket("migrations"))
/*efs := embedder.NewEmbedderVFS(app.LoadBucket("migrations"))
lfs := vfs.NewLayeredFS()
lfs.AddFS(efs)
lfs.AddFS(inst.fs)
lfs.AddFS(inst.fs)*/
lfs := inst.fs.Clone()
_ = lfs.Chdir("migrations/base/sqlite")
db := models.OpenDatabase(ctx, inst.settings)
fmt.Println("migrated database:", inst.settings.System.DSN)
@ -51,7 +51,16 @@ func (inst *installer) DoInstall(ctx context.Context, cmd *cli.Command) error {
}
func (inst *installer) DoUp(ctx context.Context, cmd *cli.Command) error {
return inst.DoInstall(ctx, cmd)
lfs := inst.fs.Clone()
_ = lfs.Chdir("migrations/sqlite")
db := models.OpenDatabase(ctx, inst.settings)
fmt.Println("migrated database:", inst.settings.System.DSN)
err := db.Migrate(lfs)
if err != nil {
inst.logger.Error(errors.Unfurl(err))
}
return nil
}
func (inst *installer) ListMigrations(ctx context.Context, cmd *cli.Command) error {

View file

@ -0,0 +1,10 @@
-- @up
alter table birthdays add column announce boolean default true not null;
-- Anniversaries will be re-added in the future, either as a base table for
-- wedding anniversaries + birthdays or as a single purpose table. If the
-- former, anniversary types will be implemented as views, and the INSTEAD OF
-- trigger will be used for inserts and updates:
-- www.sqlite.org/lang_createtrigger.html#instead_of_trigger
drop table anniversaries;

View file

@ -1,4 +1,5 @@
-- @up
-- @version=0002
-- Members and member metadata.
@ -193,7 +194,7 @@ create table verse_rotation (
verseid integer primary key,
foreign key (verseid) references verses(id)
);
create unique index verse_rotation_verseid_chatid_idx on verse_rotation (verseid, chatid);
create unique index verse_rotation_verseid_chatid_idx on verse_rotation (verseid);
create table verses_submitter (
verseid integer not null,