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