From 26c69ac46079e2d648c301b2f4e7f97215736413 Mon Sep 17 00:00:00 2001 From: im-adithya Date: Mon, 30 Oct 2023 17:43:57 +0530 Subject: [PATCH] chore: migrate internal and keysend columns to be non null --- db/migrations/20231030123456_invoice_internal.up.sql | 6 ++++++ db/migrations/20231030123456_invoice_keysend.up.sql | 6 ++++++ db/models/invoice.go | 4 ++-- 3 files changed, 14 insertions(+), 2 deletions(-) create mode 100644 db/migrations/20231030123456_invoice_internal.up.sql create mode 100644 db/migrations/20231030123456_invoice_keysend.up.sql diff --git a/db/migrations/20231030123456_invoice_internal.up.sql b/db/migrations/20231030123456_invoice_internal.up.sql new file mode 100644 index 00000000..fe5fef2e --- /dev/null +++ b/db/migrations/20231030123456_invoice_internal.up.sql @@ -0,0 +1,6 @@ +UPDATE invoices +SET internal = false +WHERE internal IS NULL; + +ALTER TABLE invoices +ALTER COLUMN internal SET NOT NULL; \ No newline at end of file diff --git a/db/migrations/20231030123456_invoice_keysend.up.sql b/db/migrations/20231030123456_invoice_keysend.up.sql new file mode 100644 index 00000000..1f76e4b3 --- /dev/null +++ b/db/migrations/20231030123456_invoice_keysend.up.sql @@ -0,0 +1,6 @@ +UPDATE invoices +SET keysend = false +WHERE keysend IS NULL; + +ALTER TABLE invoices +ALTER COLUMN keysend SET NOT NULL; \ No newline at end of file diff --git a/db/models/invoice.go b/db/models/invoice.go index ba03e5fc..c9a84f6a 100644 --- a/db/models/invoice.go +++ b/db/models/invoice.go @@ -22,8 +22,8 @@ type Invoice struct { DestinationCustomRecords map[uint64][]byte `json:"custom_records,omitempty"` RHash string `json:"r_hash"` Preimage string `json:"preimage" bun:",nullzero"` - Internal bool `json:"-" bun:",nullzero"` - Keysend bool `json:"keysend" bun:",nullzero"` + Internal bool `json:"-" bun:",notnull"` + Keysend bool `json:"keysend" bun:",notnull"` State string `json:"state" bun:",default:'initialized'"` ErrorMessage string `json:"error_message,omitempty" bun:",nullzero"` AddIndex uint64 `json:"-" bun:",nullzero"`