cic-custodial/internal/keystore/migrations.go

28 lines
516 B
Go
Raw Permalink Normal View History

2022-11-30 10:51:24 +01:00
package keystore
import (
"context"
"time"
"github.com/jackc/pgx/v5/pgxpool"
)
func applyMigration(dbPool *pgxpool.Pool) error {
2023-01-10 12:09:54 +01:00
ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)
2022-11-30 10:51:24 +01:00
defer cancel()
_, err := dbPool.Exec(ctx, `
CREATE TABLE IF NOT EXISTS keystore (
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
public_key TEXT NOT NULL,
private_key TEXT NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
`)
if err != nil {
return err
}
return nil
}