hmn/src/migration/migrations/2023-05-05T003208Z_NoDefaul...

52 lines
1.0 KiB
Go

package migrations
import (
"context"
"time"
"git.handmade.network/hmn/hmn/src/migration/types"
"github.com/jackc/pgx/v5"
)
func init() {
registerMigration(NoDefaultDiscordShowcase{})
}
type NoDefaultDiscordShowcase struct{}
func (m NoDefaultDiscordShowcase) Version() types.MigrationVersion {
return types.MigrationVersion(time.Date(2023, 5, 5, 0, 32, 8, 0, time.UTC))
}
func (m NoDefaultDiscordShowcase) Name() string {
return "NoDefaultDiscordShowcase"
}
func (m NoDefaultDiscordShowcase) Description() string {
return "Make the Discord showcase setting default to false"
}
func (m NoDefaultDiscordShowcase) Up(ctx context.Context, tx pgx.Tx) error {
_, err := tx.Exec(ctx, `
ALTER TABLE hmn_user
ALTER COLUMN discord_save_showcase SET DEFAULT FALSE
`)
if err != nil {
return err
}
return nil
}
func (m NoDefaultDiscordShowcase) Down(ctx context.Context, tx pgx.Tx) error {
_, err := tx.Exec(ctx, `
ALTER TABLE hmn_user
ALTER COLUMN discord_save_showcase SET DEFAULT TRUE
`)
if err != nil {
return err
}
return nil
}