Signed-off-by: Amolith <amolith@secluded.site>
---
deploy/tel_inventory.sql | 17 +++++++++++++++++
revert/tel_inventory.sql | 7 +++++++
sqitch.plan | 2 ++
verify/tel_inventory.sql | 16 ++++++++++++++++
4 files changed, 42 insertions(+)
create mode 100644 deploy/tel_inventory.sql
create mode 100644 revert/tel_inventory.sql
create mode 100644 verify/tel_inventory.sql
diff --git a/deploy/tel_inventory.sql b/deploy/tel_inventory.sql
new file mode 100644
index 0000000..4a4e5a0
--- /dev/null
+++ b/deploy/tel_inventory.sql
@@ -0,0 +1,17 @@
+-- Deploy jmp:tel_inventory to pg
+
+BEGIN;
+
+CREATE TABLE tel_inventory (
+ tel TEXT NOT NULL,
+ locality TEXT NOT NULL,
+ region TEXT NOT NULL,
+ bandwidth_site_id TEXT NOT NULL,
+ premium_price NUMERIC NOT NULL DEFAULT 0,
+ available_after TIMESTAMP NOT NULL DEFAULT NOW(),
+ purchased_at TIMESTAMP NOT NULL DEFAULT NOW(),
+);
+
+CREATE INDEX ON tel_inventory (tel);
+
+COMMIT;
diff --git a/revert/tel_inventory.sql b/revert/tel_inventory.sql
new file mode 100644
index 0000000..708b9c4
--- /dev/null
+++ b/revert/tel_inventory.sql
@@ -0,0 +1,7 @@
+-- Revert jmp:tel_inventory from pg
+
+BEGIN;
+
+DROP TABLE tel_inventory;
+
+COMMIT;
diff --git a/sqitch.plan b/sqitch.plan
index 20c9330..e415ef5 100644
--- a/sqitch.plan
+++ b/sqitch.plan
@@ -60,3 +60,5 @@ cdr_with_charge_ignoring_failed_noanswer [cdr_with_charge] 2023-03-28T21:35:43Z
customer_plans_with_pending [plan_log customer_plans parent_customer_id plan_log_with_range] 2023-05-03T15:05:21Z Stephen Paul Weber,,, <singpolyma@singpolyma-beefy> # Add pending boolean to the customer_plans view
@2023123 2023-05-03T15:20:20Z Stephen Paul Weber,,, <singpolyma@singpolyma-beefy> # Deploy customer_plans.pending
+
+tel_inventory 2023-09-18T17:54:30Z Amolith <amolith@secluded.site> # Add schema for tel inventory system
diff --git a/verify/tel_inventory.sql b/verify/tel_inventory.sql
new file mode 100644
index 0000000..6b8247d
--- /dev/null
+++ b/verify/tel_inventory.sql
@@ -0,0 +1,16 @@
+-- Verify jmp:tel_inventory on pg
+
+BEGIN;
+
+SELECT
+ tel,
+ locality,
+ region,
+ bandwidth_site_id,
+ premium_price,
+ available_after,
+ purchased_at
+FROM tel_inventory
+WHERE FALSE;
+
+ROLLBACK;
--
2.42.0
>+CREATE TABLE tel_inventory (
>+ tel TEXT NOT NULL,
I think tel would make a great candidate for PRIMARY KEY
>+ locality TEXT NOT NULL,
>+ region TEXT NOT NULL,
I think we will want an index on both of these since we plan to do searches
by them.
>+ available_after TIMESTAMP NOT NULL DEFAULT NOW(),
And an index here too I expect since we'll
>+SELECT
>+ tel,
>+ locality,
>+ region,
>+ bandwidth_site_id,
>+ premium_price,
>+ available_after,
>+ purchased_at
>+FROM tel_inventory
>+WHERE FALSE;
why where false?
>>+WHERE FALSE;
>
> why where false?
I was referencing other verify schemas and the couple I looked at
included WHERE FALSE, but I realise that's not helpful in this
situation. I can just remove the WHERE clause in v2.