go-urlsh/migrations/20240506000001_mfa_rename_tables.go

24 lines
1 KiB
Go
Raw Normal View History

2024-05-06 21:38:51 +02:00
package migrations
import (
"context"
"github.com/uptrace/bun"
)
func init() {
Migrations.MustRegister(func(ctx context.Context, db *bun.DB) error {
db.ExecContext(context.Background(), `ALTER TABLE multifactor RENAME COLUMN expiresat TO expires_at`)
db.ExecContext(context.Background(), `ALTER TABLE multifactor RENAME COLUMN totpurl TO totp_secret`)
db.ExecContext(context.Background(), `ALTER TABLE users RENAME COLUMN lastlogin TO last_login`)
db.ExecContext(context.Background(), `ALTER TABLE multifactor_scratchcodes RENAME COLUMN isused TO is_used`)
return nil
}, func(ctx context.Context, db *bun.DB) error {
db.ExecContext(context.Background(), `ALTER TABLE multifactor RENAME COLUMN expires_at TO expiresat`)
db.ExecContext(context.Background(), `ALTER TABLE multifactor RENAME COLUMN totp_secret TO totpurl`)
db.ExecContext(context.Background(), `ALTER TABLE users RENAME COLUMN last_login TO lastlogin`)
db.ExecContext(context.Background(), `ALTER TABLE multifactor_scratchcodes RENAME COLUMN is_used TO isused`)
return nil
})
}