20 lines
643 B
Go
20 lines
643 B
Go
|
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 logins ALTER COLUMN cookie SET DATA TYPE VARCHAR`)
|
||
|
db.ExecContext(context.Background(), `TRUNCATE TABLE logins`)
|
||
|
return nil
|
||
|
}, func(ctx context.Context, db *bun.DB) error {
|
||
|
db.ExecContext(context.Background(), `ALTER TABLE logins ALTER COLUMN cookie SET DATA TYPE UUID USING (gen_random_uuid());`)
|
||
|
db.ExecContext(context.Background(), `ALTER TABLE logins ALTER COLUMN cookie SET DEFAULT gen_random_uuid();`)
|
||
|
return nil
|
||
|
})
|
||
|
}
|