Overhaul publicreport storage layer, create unified tables

This is a huge change. I was getting really sick of the split between
nuisance/water tables when more than half of the data they store is
common. I finally bit off the big work of switching it all.

This creates a single unified table, publicreport.report and copies the
existing report data into it. It also ports existing data from the
original tables into the new table.

Along with all of this I also overhauled the system for handling
asynchronous work to use a LISTEN/NOTIFY connection from the database
and a single cache table to avoid ever losing work.
This commit is contained in:
Eli Ribble 2026-03-18 15:36:20 +00:00
parent 2538638c9d
commit 1e071d5ce5
No known key found for this signature in database
109 changed files with 22903 additions and 11713 deletions

View file

@ -78,6 +78,24 @@ var CommsTextJobs = Table[
Generated: false,
AutoIncr: false,
},
CreatorID: column{
Name: "creator_id",
DBType: "integer",
Default: "NULL",
Comment: "",
Nullable: true,
Generated: false,
AutoIncr: false,
},
ReportID: column{
Name: "report_id",
DBType: "integer",
Default: "NULL",
Comment: "",
Nullable: true,
Generated: false,
AutoIncr: false,
},
},
Indexes: commsTextJobIndexes{
TextJobPkey: index{
@ -104,6 +122,15 @@ var CommsTextJobs = Table[
Comment: "",
},
ForeignKeys: commsTextJobForeignKeys{
CommsTextJobTextJobCreatorIDFkey: foreignKey{
constraint: constraint{
Name: "comms.text_job.text_job_creator_id_fkey",
Columns: []string{"creator_id"},
Comment: "",
},
ForeignTable: "user_",
ForeignColumns: []string{"id"},
},
CommsTextJobTextJobDestinationFkey: foreignKey{
constraint: constraint{
Name: "comms.text_job.text_job_destination_fkey",
@ -113,6 +140,15 @@ var CommsTextJobs = Table[
ForeignTable: "comms.phone",
ForeignColumns: []string{"e164"},
},
CommsTextJobTextJobReportIDFkey: foreignKey{
constraint: constraint{
Name: "comms.text_job.text_job_report_id_fkey",
Columns: []string{"report_id"},
Comment: "",
},
ForeignTable: "publicreport.report",
ForeignColumns: []string{"id"},
},
},
Comment: "Used to track text messages that should be sent later",
@ -126,11 +162,13 @@ type commsTextJobColumns struct {
Type column
Source column
Completed column
CreatorID column
ReportID column
}
func (c commsTextJobColumns) AsSlice() []column {
return []column{
c.Content, c.Created, c.Destination, c.ID, c.Type, c.Source, c.Completed,
c.Content, c.Created, c.Destination, c.ID, c.Type, c.Source, c.Completed, c.CreatorID, c.ReportID,
}
}
@ -145,12 +183,14 @@ func (i commsTextJobIndexes) AsSlice() []index {
}
type commsTextJobForeignKeys struct {
CommsTextJobTextJobCreatorIDFkey foreignKey
CommsTextJobTextJobDestinationFkey foreignKey
CommsTextJobTextJobReportIDFkey foreignKey
}
func (f commsTextJobForeignKeys) AsSlice() []foreignKey {
return []foreignKey{
f.CommsTextJobTextJobDestinationFkey,
f.CommsTextJobTextJobCreatorIDFkey, f.CommsTextJobTextJobDestinationFkey, f.CommsTextJobTextJobReportIDFkey,
}
}