Add pubkey column to market table
This commit is contained in:
parent
6ab8e975fb
commit
938bff20e6
@ -31,6 +31,7 @@ CREATE TABLE markets(
|
||||
id SERIAL PRIMARY KEY,
|
||||
description TEXT NOT NULL,
|
||||
end_date TIMESTAMP WITH TIME ZONE NOT NULL,
|
||||
pubkey TEXT NOT NULL REFERENCES users(pubkey),
|
||||
invoice_id UUID NOT NULL UNIQUE REFERENCES invoices(id)
|
||||
);
|
||||
CREATE EXTENSION "uuid-ossp";
|
||||
|
@ -15,9 +15,9 @@ type FetchOrdersWhere struct {
|
||||
|
||||
func (db *DB) CreateMarket(tx *sql.Tx, ctx context.Context, market *Market) error {
|
||||
if err := tx.QueryRowContext(ctx, ""+
|
||||
"INSERT INTO markets(description, end_date, invoice_id) "+
|
||||
"VALUES($1, $2, $3) "+
|
||||
"RETURNING id", market.Description, market.EndDate, market.InvoiceId).Scan(&market.Id); err != nil {
|
||||
"INSERT INTO markets(description, end_date, pubkey, invoice_id) "+
|
||||
"VALUES($1, $2, $3, $4) "+
|
||||
"RETURNING id", market.Description, market.EndDate, market.Pubkey, market.InvoiceId).Scan(&market.Id); err != nil {
|
||||
return err
|
||||
}
|
||||
// For now, we only support binary markets.
|
||||
|
@ -29,6 +29,7 @@ type (
|
||||
Id Serial `json:"id"`
|
||||
Description string `json:"description"`
|
||||
EndDate time.Time `json:"endDate"`
|
||||
Pubkey string
|
||||
InvoiceId UUID
|
||||
}
|
||||
Share struct {
|
||||
|
@ -93,6 +93,7 @@ func HandleCreateMarket(sc context.ServerContext) echo.HandlerFunc {
|
||||
defer tx.Commit()
|
||||
|
||||
u = c.Get("session").(db.User)
|
||||
m.Pubkey = u.Pubkey
|
||||
msats = 1000
|
||||
// TODO: add [market:<id>] for redirect after payment
|
||||
invDescription = fmt.Sprintf("create market \"%s\"", m.Description)
|
||||
|
Loading…
x
Reference in New Issue
Block a user