Add contacts, rework comms schema
This in a pretty huge change. At a high level we're adding the concept of a 'contact' which is a person or organization that has zero or more contact methods (email, phone). This ended up cascading a number of changes, including critically to the publicreprt schema. In the end it seemed safer to get to the point where I'm confident we aren't using any of the old fields for storing reporter information (though I haven't deleted the columns yet) so I removed the code for defining those columns. At this point I think it's not possible for me to regenerate the bob schema due to the interdependencies between my various schemas, so the migration is well-and-truly happening.
This commit is contained in:
parent
085935fa66
commit
f1fe8b4d2b
46 changed files with 1127 additions and 633 deletions
|
|
@ -153,28 +153,23 @@ func (publicreportReportColumns) AliasedAs(alias string) publicreportReportColum
|
|||
// All values are optional, and do not have to be set
|
||||
// Generated columns are not included
|
||||
type PublicreportReportSetter struct {
|
||||
AddressRaw omit.Val[string] `db:"address_raw" `
|
||||
AddressID omitnull.Val[int32] `db:"address_id" `
|
||||
Created omit.Val[time.Time] `db:"created" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
H3cell omitnull.Val[string] `db:"h3cell" `
|
||||
ID omit.Val[int32] `db:"id,pk" `
|
||||
LatlngAccuracyType omit.Val[enums.PublicreportAccuracytype] `db:"latlng_accuracy_type" `
|
||||
LatlngAccuracyValue omit.Val[float32] `db:"latlng_accuracy_value" `
|
||||
MapZoom omit.Val[float32] `db:"map_zoom" `
|
||||
OrganizationID omit.Val[int32] `db:"organization_id" `
|
||||
PublicID omit.Val[string] `db:"public_id" `
|
||||
ReporterName omit.Val[string] `db:"reporter_name" `
|
||||
ReporterEmail omit.Val[string] `db:"reporter_email" `
|
||||
ReporterPhone omit.Val[string] `db:"reporter_phone" `
|
||||
ReporterContactConsent omitnull.Val[bool] `db:"reporter_contact_consent" `
|
||||
ReportType omit.Val[enums.PublicreportReporttype] `db:"report_type" `
|
||||
Reviewed omitnull.Val[time.Time] `db:"reviewed" `
|
||||
ReviewerID omitnull.Val[int32] `db:"reviewer_id" `
|
||||
Status omit.Val[enums.PublicreportReportstatustype] `db:"status" `
|
||||
AddressGid omit.Val[string] `db:"address_gid" `
|
||||
ClientUUID omitnull.Val[uuid.UUID] `db:"client_uuid" `
|
||||
ReporterPhoneCanSMS omit.Val[bool] `db:"reporter_phone_can_sms" `
|
||||
AddressRaw omit.Val[string] `db:"address_raw" `
|
||||
AddressID omitnull.Val[int32] `db:"address_id" `
|
||||
Created omit.Val[time.Time] `db:"created" `
|
||||
Location omitnull.Val[string] `db:"location" `
|
||||
H3cell omitnull.Val[string] `db:"h3cell" `
|
||||
ID omit.Val[int32] `db:"id,pk" `
|
||||
LatlngAccuracyType omit.Val[enums.PublicreportAccuracytype] `db:"latlng_accuracy_type" `
|
||||
LatlngAccuracyValue omit.Val[float32] `db:"latlng_accuracy_value" `
|
||||
MapZoom omit.Val[float32] `db:"map_zoom" `
|
||||
OrganizationID omit.Val[int32] `db:"organization_id" `
|
||||
PublicID omit.Val[string] `db:"public_id" `
|
||||
ReportType omit.Val[enums.PublicreportReporttype] `db:"report_type" `
|
||||
Reviewed omitnull.Val[time.Time] `db:"reviewed" `
|
||||
ReviewerID omitnull.Val[int32] `db:"reviewer_id" `
|
||||
Status omit.Val[enums.PublicreportReportstatustype] `db:"status" `
|
||||
AddressGid omit.Val[string] `db:"address_gid" `
|
||||
ClientUUID omitnull.Val[uuid.UUID] `db:"client_uuid" `
|
||||
}
|
||||
|
||||
func (s PublicreportReportSetter) SetColumns() []string {
|
||||
|
|
@ -212,18 +207,6 @@ func (s PublicreportReportSetter) SetColumns() []string {
|
|||
if s.PublicID.IsValue() {
|
||||
vals = append(vals, "public_id")
|
||||
}
|
||||
if s.ReporterName.IsValue() {
|
||||
vals = append(vals, "reporter_name")
|
||||
}
|
||||
if s.ReporterEmail.IsValue() {
|
||||
vals = append(vals, "reporter_email")
|
||||
}
|
||||
if s.ReporterPhone.IsValue() {
|
||||
vals = append(vals, "reporter_phone")
|
||||
}
|
||||
if !s.ReporterContactConsent.IsUnset() {
|
||||
vals = append(vals, "reporter_contact_consent")
|
||||
}
|
||||
if s.ReportType.IsValue() {
|
||||
vals = append(vals, "report_type")
|
||||
}
|
||||
|
|
@ -242,9 +225,6 @@ func (s PublicreportReportSetter) SetColumns() []string {
|
|||
if !s.ClientUUID.IsUnset() {
|
||||
vals = append(vals, "client_uuid")
|
||||
}
|
||||
if s.ReporterPhoneCanSMS.IsValue() {
|
||||
vals = append(vals, "reporter_phone_can_sms")
|
||||
}
|
||||
return vals
|
||||
}
|
||||
|
||||
|
|
@ -282,18 +262,6 @@ func (s PublicreportReportSetter) Overwrite(t *PublicreportReport) {
|
|||
if s.PublicID.IsValue() {
|
||||
t.PublicID = s.PublicID.MustGet()
|
||||
}
|
||||
if s.ReporterName.IsValue() {
|
||||
t.ReporterName = s.ReporterName.MustGet()
|
||||
}
|
||||
if s.ReporterEmail.IsValue() {
|
||||
t.ReporterEmail = s.ReporterEmail.MustGet()
|
||||
}
|
||||
if s.ReporterPhone.IsValue() {
|
||||
t.ReporterPhone = s.ReporterPhone.MustGet()
|
||||
}
|
||||
if !s.ReporterContactConsent.IsUnset() {
|
||||
t.ReporterContactConsent = s.ReporterContactConsent.MustGetNull()
|
||||
}
|
||||
if s.ReportType.IsValue() {
|
||||
t.ReportType = s.ReportType.MustGet()
|
||||
}
|
||||
|
|
@ -312,9 +280,6 @@ func (s PublicreportReportSetter) Overwrite(t *PublicreportReport) {
|
|||
if !s.ClientUUID.IsUnset() {
|
||||
t.ClientUUID = s.ClientUUID.MustGetNull()
|
||||
}
|
||||
if s.ReporterPhoneCanSMS.IsValue() {
|
||||
t.ReporterPhoneCanSMS = s.ReporterPhoneCanSMS.MustGet()
|
||||
}
|
||||
}
|
||||
|
||||
func (s *PublicreportReportSetter) Apply(q *dialect.InsertQuery) {
|
||||
|
|
@ -390,29 +355,13 @@ func (s *PublicreportReportSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[10] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.ReporterName.IsValue() {
|
||||
vals[11] = psql.Arg(s.ReporterName.MustGet())
|
||||
} else {
|
||||
vals[11] = psql.Raw("DEFAULT")
|
||||
}
|
||||
vals[11] = psql.Raw("DEFAULT")
|
||||
|
||||
if s.ReporterEmail.IsValue() {
|
||||
vals[12] = psql.Arg(s.ReporterEmail.MustGet())
|
||||
} else {
|
||||
vals[12] = psql.Raw("DEFAULT")
|
||||
}
|
||||
vals[12] = psql.Raw("DEFAULT")
|
||||
|
||||
if s.ReporterPhone.IsValue() {
|
||||
vals[13] = psql.Arg(s.ReporterPhone.MustGet())
|
||||
} else {
|
||||
vals[13] = psql.Raw("DEFAULT")
|
||||
}
|
||||
vals[13] = psql.Raw("DEFAULT")
|
||||
|
||||
if !s.ReporterContactConsent.IsUnset() {
|
||||
vals[14] = psql.Arg(s.ReporterContactConsent.MustGetNull())
|
||||
} else {
|
||||
vals[14] = psql.Raw("DEFAULT")
|
||||
}
|
||||
vals[14] = psql.Raw("DEFAULT")
|
||||
|
||||
if s.ReportType.IsValue() {
|
||||
vals[15] = psql.Arg(s.ReportType.MustGet())
|
||||
|
|
@ -450,11 +399,7 @@ func (s *PublicreportReportSetter) Apply(q *dialect.InsertQuery) {
|
|||
vals[20] = psql.Raw("DEFAULT")
|
||||
}
|
||||
|
||||
if s.ReporterPhoneCanSMS.IsValue() {
|
||||
vals[21] = psql.Arg(s.ReporterPhoneCanSMS.MustGet())
|
||||
} else {
|
||||
vals[21] = psql.Raw("DEFAULT")
|
||||
}
|
||||
vals[21] = psql.Raw("DEFAULT")
|
||||
|
||||
return bob.ExpressSlice(ctx, w, d, start, vals, "", ", ", "")
|
||||
}))
|
||||
|
|
@ -544,34 +489,6 @@ func (s PublicreportReportSetter) Expressions(prefix ...string) []bob.Expression
|
|||
}})
|
||||
}
|
||||
|
||||
if s.ReporterName.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "reporter_name")...),
|
||||
psql.Arg(s.ReporterName),
|
||||
}})
|
||||
}
|
||||
|
||||
if s.ReporterEmail.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "reporter_email")...),
|
||||
psql.Arg(s.ReporterEmail),
|
||||
}})
|
||||
}
|
||||
|
||||
if s.ReporterPhone.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "reporter_phone")...),
|
||||
psql.Arg(s.ReporterPhone),
|
||||
}})
|
||||
}
|
||||
|
||||
if !s.ReporterContactConsent.IsUnset() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "reporter_contact_consent")...),
|
||||
psql.Arg(s.ReporterContactConsent),
|
||||
}})
|
||||
}
|
||||
|
||||
if s.ReportType.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "report_type")...),
|
||||
|
|
@ -614,13 +531,6 @@ func (s PublicreportReportSetter) Expressions(prefix ...string) []bob.Expression
|
|||
}})
|
||||
}
|
||||
|
||||
if s.ReporterPhoneCanSMS.IsValue() {
|
||||
exprs = append(exprs, expr.Join{Sep: " = ", Exprs: []bob.Expression{
|
||||
psql.Quote(append(prefix, "reporter_phone_can_sms")...),
|
||||
psql.Arg(s.ReporterPhoneCanSMS),
|
||||
}})
|
||||
}
|
||||
|
||||
return exprs
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue