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
19
db/gen/nidus-sync/comms/model/contact.go
Normal file
19
db/gen/nidus-sync/comms/model/contact.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
//
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Contact struct {
|
||||
Created time.Time
|
||||
ID int32 `sql:"primary_key"`
|
||||
Name string
|
||||
OrganizationID int32
|
||||
}
|
||||
16
db/gen/nidus-sync/comms/model/contact_email.go
Normal file
16
db/gen/nidus-sync/comms/model/contact_email.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
//
|
||||
|
||||
package model
|
||||
|
||||
type ContactEmail struct {
|
||||
Address string `sql:"primary_key"`
|
||||
Confirmed bool
|
||||
ContactID int32
|
||||
ID int32
|
||||
IsSubscribed bool
|
||||
}
|
||||
17
db/gen/nidus-sync/comms/model/contact_phone.go
Normal file
17
db/gen/nidus-sync/comms/model/contact_phone.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
//
|
||||
|
||||
package model
|
||||
|
||||
type ContactPhone struct {
|
||||
CanSms bool
|
||||
ConfirmedMessageID *int32
|
||||
ContactID int32
|
||||
E164 string `sql:"primary_key"`
|
||||
IsSubscribed bool
|
||||
StopMessageID *int32
|
||||
}
|
||||
87
db/gen/nidus-sync/comms/table/contact.go
Normal file
87
db/gen/nidus-sync/comms/table/contact.go
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
//
|
||||
|
||||
package table
|
||||
|
||||
import (
|
||||
"github.com/Gleipnir-Technology/jet/postgres"
|
||||
)
|
||||
|
||||
var Contact = newContactTable("comms", "contact", "")
|
||||
|
||||
type contactTable struct {
|
||||
postgres.Table
|
||||
|
||||
// Columns
|
||||
Created postgres.ColumnTimestamp
|
||||
ID postgres.ColumnInteger
|
||||
Name postgres.ColumnString
|
||||
OrganizationID postgres.ColumnInteger
|
||||
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
DefaultColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
type ContactTable struct {
|
||||
contactTable
|
||||
|
||||
EXCLUDED contactTable
|
||||
}
|
||||
|
||||
// AS creates new ContactTable with assigned alias
|
||||
func (a ContactTable) AS(alias string) *ContactTable {
|
||||
return newContactTable(a.SchemaName(), a.TableName(), alias)
|
||||
}
|
||||
|
||||
// Schema creates new ContactTable with assigned schema name
|
||||
func (a ContactTable) FromSchema(schemaName string) *ContactTable {
|
||||
return newContactTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new ContactTable with assigned table prefix
|
||||
func (a ContactTable) WithPrefix(prefix string) *ContactTable {
|
||||
return newContactTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new ContactTable with assigned table suffix
|
||||
func (a ContactTable) WithSuffix(suffix string) *ContactTable {
|
||||
return newContactTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newContactTable(schemaName, tableName, alias string) *ContactTable {
|
||||
return &ContactTable{
|
||||
contactTable: newContactTableImpl(schemaName, tableName, alias),
|
||||
EXCLUDED: newContactTableImpl("", "excluded", ""),
|
||||
}
|
||||
}
|
||||
|
||||
func newContactTableImpl(schemaName, tableName, alias string) contactTable {
|
||||
var (
|
||||
CreatedColumn = postgres.TimestampColumn("created")
|
||||
IDColumn = postgres.IntegerColumn("id")
|
||||
NameColumn = postgres.StringColumn("name")
|
||||
OrganizationIDColumn = postgres.IntegerColumn("organization_id")
|
||||
allColumns = postgres.ColumnList{CreatedColumn, IDColumn, NameColumn, OrganizationIDColumn}
|
||||
mutableColumns = postgres.ColumnList{CreatedColumn, NameColumn, OrganizationIDColumn}
|
||||
defaultColumns = postgres.ColumnList{IDColumn}
|
||||
)
|
||||
|
||||
return contactTable{
|
||||
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||
|
||||
//Columns
|
||||
Created: CreatedColumn,
|
||||
ID: IDColumn,
|
||||
Name: NameColumn,
|
||||
OrganizationID: OrganizationIDColumn,
|
||||
|
||||
AllColumns: allColumns,
|
||||
MutableColumns: mutableColumns,
|
||||
DefaultColumns: defaultColumns,
|
||||
}
|
||||
}
|
||||
90
db/gen/nidus-sync/comms/table/contact_email.go
Normal file
90
db/gen/nidus-sync/comms/table/contact_email.go
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
//
|
||||
|
||||
package table
|
||||
|
||||
import (
|
||||
"github.com/Gleipnir-Technology/jet/postgres"
|
||||
)
|
||||
|
||||
var ContactEmail = newContactEmailTable("comms", "contact_email", "")
|
||||
|
||||
type contactEmailTable struct {
|
||||
postgres.Table
|
||||
|
||||
// Columns
|
||||
Address postgres.ColumnString
|
||||
Confirmed postgres.ColumnBool
|
||||
ContactID postgres.ColumnInteger
|
||||
ID postgres.ColumnInteger
|
||||
IsSubscribed postgres.ColumnBool
|
||||
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
DefaultColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
type ContactEmailTable struct {
|
||||
contactEmailTable
|
||||
|
||||
EXCLUDED contactEmailTable
|
||||
}
|
||||
|
||||
// AS creates new ContactEmailTable with assigned alias
|
||||
func (a ContactEmailTable) AS(alias string) *ContactEmailTable {
|
||||
return newContactEmailTable(a.SchemaName(), a.TableName(), alias)
|
||||
}
|
||||
|
||||
// Schema creates new ContactEmailTable with assigned schema name
|
||||
func (a ContactEmailTable) FromSchema(schemaName string) *ContactEmailTable {
|
||||
return newContactEmailTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new ContactEmailTable with assigned table prefix
|
||||
func (a ContactEmailTable) WithPrefix(prefix string) *ContactEmailTable {
|
||||
return newContactEmailTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new ContactEmailTable with assigned table suffix
|
||||
func (a ContactEmailTable) WithSuffix(suffix string) *ContactEmailTable {
|
||||
return newContactEmailTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newContactEmailTable(schemaName, tableName, alias string) *ContactEmailTable {
|
||||
return &ContactEmailTable{
|
||||
contactEmailTable: newContactEmailTableImpl(schemaName, tableName, alias),
|
||||
EXCLUDED: newContactEmailTableImpl("", "excluded", ""),
|
||||
}
|
||||
}
|
||||
|
||||
func newContactEmailTableImpl(schemaName, tableName, alias string) contactEmailTable {
|
||||
var (
|
||||
AddressColumn = postgres.StringColumn("address")
|
||||
ConfirmedColumn = postgres.BoolColumn("confirmed")
|
||||
ContactIDColumn = postgres.IntegerColumn("contact_id")
|
||||
IDColumn = postgres.IntegerColumn("id")
|
||||
IsSubscribedColumn = postgres.BoolColumn("is_subscribed")
|
||||
allColumns = postgres.ColumnList{AddressColumn, ConfirmedColumn, ContactIDColumn, IDColumn, IsSubscribedColumn}
|
||||
mutableColumns = postgres.ColumnList{ConfirmedColumn, ContactIDColumn, IDColumn, IsSubscribedColumn}
|
||||
defaultColumns = postgres.ColumnList{IDColumn}
|
||||
)
|
||||
|
||||
return contactEmailTable{
|
||||
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||
|
||||
//Columns
|
||||
Address: AddressColumn,
|
||||
Confirmed: ConfirmedColumn,
|
||||
ContactID: ContactIDColumn,
|
||||
ID: IDColumn,
|
||||
IsSubscribed: IsSubscribedColumn,
|
||||
|
||||
AllColumns: allColumns,
|
||||
MutableColumns: mutableColumns,
|
||||
DefaultColumns: defaultColumns,
|
||||
}
|
||||
}
|
||||
93
db/gen/nidus-sync/comms/table/contact_phone.go
Normal file
93
db/gen/nidus-sync/comms/table/contact_phone.go
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
//
|
||||
// Code generated by go-jet DO NOT EDIT.
|
||||
//
|
||||
// WARNING: Changes to this file may cause incorrect behavior
|
||||
// and will be lost if the code is regenerated
|
||||
//
|
||||
|
||||
package table
|
||||
|
||||
import (
|
||||
"github.com/Gleipnir-Technology/jet/postgres"
|
||||
)
|
||||
|
||||
var ContactPhone = newContactPhoneTable("comms", "contact_phone", "")
|
||||
|
||||
type contactPhoneTable struct {
|
||||
postgres.Table
|
||||
|
||||
// Columns
|
||||
CanSms postgres.ColumnBool
|
||||
ConfirmedMessageID postgres.ColumnInteger
|
||||
ContactID postgres.ColumnInteger
|
||||
E164 postgres.ColumnString
|
||||
IsSubscribed postgres.ColumnBool
|
||||
StopMessageID postgres.ColumnInteger
|
||||
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
DefaultColumns postgres.ColumnList
|
||||
}
|
||||
|
||||
type ContactPhoneTable struct {
|
||||
contactPhoneTable
|
||||
|
||||
EXCLUDED contactPhoneTable
|
||||
}
|
||||
|
||||
// AS creates new ContactPhoneTable with assigned alias
|
||||
func (a ContactPhoneTable) AS(alias string) *ContactPhoneTable {
|
||||
return newContactPhoneTable(a.SchemaName(), a.TableName(), alias)
|
||||
}
|
||||
|
||||
// Schema creates new ContactPhoneTable with assigned schema name
|
||||
func (a ContactPhoneTable) FromSchema(schemaName string) *ContactPhoneTable {
|
||||
return newContactPhoneTable(schemaName, a.TableName(), a.Alias())
|
||||
}
|
||||
|
||||
// WithPrefix creates new ContactPhoneTable with assigned table prefix
|
||||
func (a ContactPhoneTable) WithPrefix(prefix string) *ContactPhoneTable {
|
||||
return newContactPhoneTable(a.SchemaName(), prefix+a.TableName(), a.TableName())
|
||||
}
|
||||
|
||||
// WithSuffix creates new ContactPhoneTable with assigned table suffix
|
||||
func (a ContactPhoneTable) WithSuffix(suffix string) *ContactPhoneTable {
|
||||
return newContactPhoneTable(a.SchemaName(), a.TableName()+suffix, a.TableName())
|
||||
}
|
||||
|
||||
func newContactPhoneTable(schemaName, tableName, alias string) *ContactPhoneTable {
|
||||
return &ContactPhoneTable{
|
||||
contactPhoneTable: newContactPhoneTableImpl(schemaName, tableName, alias),
|
||||
EXCLUDED: newContactPhoneTableImpl("", "excluded", ""),
|
||||
}
|
||||
}
|
||||
|
||||
func newContactPhoneTableImpl(schemaName, tableName, alias string) contactPhoneTable {
|
||||
var (
|
||||
CanSmsColumn = postgres.BoolColumn("can_sms")
|
||||
ConfirmedMessageIDColumn = postgres.IntegerColumn("confirmed_message_id")
|
||||
ContactIDColumn = postgres.IntegerColumn("contact_id")
|
||||
E164Column = postgres.StringColumn("e164")
|
||||
IsSubscribedColumn = postgres.BoolColumn("is_subscribed")
|
||||
StopMessageIDColumn = postgres.IntegerColumn("stop_message_id")
|
||||
allColumns = postgres.ColumnList{CanSmsColumn, ConfirmedMessageIDColumn, ContactIDColumn, E164Column, IsSubscribedColumn, StopMessageIDColumn}
|
||||
mutableColumns = postgres.ColumnList{CanSmsColumn, ConfirmedMessageIDColumn, ContactIDColumn, IsSubscribedColumn, StopMessageIDColumn}
|
||||
defaultColumns = postgres.ColumnList{}
|
||||
)
|
||||
|
||||
return contactPhoneTable{
|
||||
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||
|
||||
//Columns
|
||||
CanSms: CanSmsColumn,
|
||||
ConfirmedMessageID: ConfirmedMessageIDColumn,
|
||||
ContactID: ContactIDColumn,
|
||||
E164: E164Column,
|
||||
IsSubscribed: IsSubscribedColumn,
|
||||
StopMessageID: StopMessageIDColumn,
|
||||
|
||||
AllColumns: allColumns,
|
||||
MutableColumns: mutableColumns,
|
||||
DefaultColumns: defaultColumns,
|
||||
}
|
||||
}
|
||||
|
|
@ -10,6 +10,9 @@ package table
|
|||
// UseSchema sets a new schema name for all generated table SQL builder types. It is recommended to invoke
|
||||
// this method only once at the beginning of the program.
|
||||
func UseSchema(schema string) {
|
||||
Contact = Contact.FromSchema(schema)
|
||||
ContactEmail = ContactEmail.FromSchema(schema)
|
||||
ContactPhone = ContactPhone.FromSchema(schema)
|
||||
EmailContact = EmailContact.FromSchema(schema)
|
||||
EmailLog = EmailLog.FromSchema(schema)
|
||||
EmailTemplate = EmailTemplate.FromSchema(schema)
|
||||
|
|
|
|||
|
|
@ -36,4 +36,5 @@ type Report struct {
|
|||
AddressGid string
|
||||
ClientUUID *uuid.UUID
|
||||
ReporterPhoneCanSms bool
|
||||
ReporterContactID *int32
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ type reportTable struct {
|
|||
AddressGid postgres.ColumnString
|
||||
ClientUUID postgres.ColumnString
|
||||
ReporterPhoneCanSms postgres.ColumnBool
|
||||
ReporterContactID postgres.ColumnInteger
|
||||
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
|
|
@ -102,8 +103,9 @@ func newReportTableImpl(schemaName, tableName, alias string) reportTable {
|
|||
AddressGidColumn = postgres.StringColumn("address_gid")
|
||||
ClientUUIDColumn = postgres.StringColumn("client_uuid")
|
||||
ReporterPhoneCanSmsColumn = postgres.BoolColumn("reporter_phone_can_sms")
|
||||
allColumns = postgres.ColumnList{AddressRawColumn, AddressIDColumn, CreatedColumn, LocationColumn, H3cellColumn, IDColumn, LatlngAccuracyTypeColumn, LatlngAccuracyValueColumn, MapZoomColumn, OrganizationIDColumn, PublicIDColumn, ReporterNameColumn, ReporterEmailColumn, ReporterPhoneColumn, ReporterContactConsentColumn, ReportTypeColumn, ReviewedColumn, ReviewerIDColumn, StatusColumn, AddressGidColumn, ClientUUIDColumn, ReporterPhoneCanSmsColumn}
|
||||
mutableColumns = postgres.ColumnList{AddressRawColumn, AddressIDColumn, CreatedColumn, LocationColumn, H3cellColumn, LatlngAccuracyTypeColumn, LatlngAccuracyValueColumn, MapZoomColumn, OrganizationIDColumn, PublicIDColumn, ReporterNameColumn, ReporterEmailColumn, ReporterPhoneColumn, ReporterContactConsentColumn, ReportTypeColumn, ReviewedColumn, ReviewerIDColumn, StatusColumn, AddressGidColumn, ClientUUIDColumn, ReporterPhoneCanSmsColumn}
|
||||
ReporterContactIDColumn = postgres.IntegerColumn("reporter_contact_id")
|
||||
allColumns = postgres.ColumnList{AddressRawColumn, AddressIDColumn, CreatedColumn, LocationColumn, H3cellColumn, IDColumn, LatlngAccuracyTypeColumn, LatlngAccuracyValueColumn, MapZoomColumn, OrganizationIDColumn, PublicIDColumn, ReporterNameColumn, ReporterEmailColumn, ReporterPhoneColumn, ReporterContactConsentColumn, ReportTypeColumn, ReviewedColumn, ReviewerIDColumn, StatusColumn, AddressGidColumn, ClientUUIDColumn, ReporterPhoneCanSmsColumn, ReporterContactIDColumn}
|
||||
mutableColumns = postgres.ColumnList{AddressRawColumn, AddressIDColumn, CreatedColumn, LocationColumn, H3cellColumn, LatlngAccuracyTypeColumn, LatlngAccuracyValueColumn, MapZoomColumn, OrganizationIDColumn, PublicIDColumn, ReporterNameColumn, ReporterEmailColumn, ReporterPhoneColumn, ReporterContactConsentColumn, ReportTypeColumn, ReviewedColumn, ReviewerIDColumn, StatusColumn, AddressGidColumn, ClientUUIDColumn, ReporterPhoneCanSmsColumn, ReporterContactIDColumn}
|
||||
defaultColumns = postgres.ColumnList{IDColumn}
|
||||
)
|
||||
|
||||
|
|
@ -133,6 +135,7 @@ func newReportTableImpl(schemaName, tableName, alias string) reportTable {
|
|||
AddressGid: AddressGidColumn,
|
||||
ClientUUID: ClientUUIDColumn,
|
||||
ReporterPhoneCanSms: ReporterPhoneCanSmsColumn,
|
||||
ReporterContactID: ReporterContactIDColumn,
|
||||
|
||||
AllColumns: allColumns,
|
||||
MutableColumns: mutableColumns,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue