Move properties of phones to the phone, not contact_phone
This makes sense because there will naturally be cases where multiple districts have the same phone number mapped to different contacts.
This commit is contained in:
parent
f957dc6982
commit
7b04822a9b
14 changed files with 143 additions and 104 deletions
|
|
@ -8,11 +8,8 @@
|
|||
package model
|
||||
|
||||
type ContactPhone struct {
|
||||
CanSms bool
|
||||
ConfirmedMessageID *int32
|
||||
ContactID int32
|
||||
E164 string
|
||||
IsSubscribed bool
|
||||
StopMessageID *int32
|
||||
ID int32 `sql:"primary_key"`
|
||||
ContactID int32
|
||||
E164 string
|
||||
IsSubscribed bool
|
||||
ID int32 `sql:"primary_key"`
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@
|
|||
package model
|
||||
|
||||
type Phone struct {
|
||||
E164 string `sql:"primary_key"`
|
||||
IsSubscribed bool
|
||||
Status Phonestatustype
|
||||
CanSms bool
|
||||
E164 string `sql:"primary_key"`
|
||||
CanSms bool
|
||||
ConfirmedMessageID *int32
|
||||
StopMessageID *int32
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,13 +17,10 @@ type contactPhoneTable struct {
|
|||
postgres.Table
|
||||
|
||||
// Columns
|
||||
CanSms postgres.ColumnBool
|
||||
ConfirmedMessageID postgres.ColumnInteger
|
||||
ContactID postgres.ColumnInteger
|
||||
E164 postgres.ColumnString
|
||||
IsSubscribed postgres.ColumnBool
|
||||
StopMessageID postgres.ColumnInteger
|
||||
ID postgres.ColumnInteger
|
||||
ContactID postgres.ColumnInteger
|
||||
E164 postgres.ColumnString
|
||||
IsSubscribed postgres.ColumnBool
|
||||
ID postgres.ColumnInteger
|
||||
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
|
|
@ -65,29 +62,23 @@ func newContactPhoneTable(schemaName, tableName, alias string) *ContactPhoneTabl
|
|||
|
||||
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")
|
||||
IDColumn = postgres.IntegerColumn("id")
|
||||
allColumns = postgres.ColumnList{CanSmsColumn, ConfirmedMessageIDColumn, ContactIDColumn, E164Column, IsSubscribedColumn, StopMessageIDColumn, IDColumn}
|
||||
mutableColumns = postgres.ColumnList{CanSmsColumn, ConfirmedMessageIDColumn, ContactIDColumn, E164Column, IsSubscribedColumn, StopMessageIDColumn}
|
||||
defaultColumns = postgres.ColumnList{IDColumn}
|
||||
ContactIDColumn = postgres.IntegerColumn("contact_id")
|
||||
E164Column = postgres.StringColumn("e164")
|
||||
IsSubscribedColumn = postgres.BoolColumn("is_subscribed")
|
||||
IDColumn = postgres.IntegerColumn("id")
|
||||
allColumns = postgres.ColumnList{ContactIDColumn, E164Column, IsSubscribedColumn, IDColumn}
|
||||
mutableColumns = postgres.ColumnList{ContactIDColumn, E164Column, IsSubscribedColumn}
|
||||
defaultColumns = postgres.ColumnList{IDColumn}
|
||||
)
|
||||
|
||||
return contactPhoneTable{
|
||||
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||
|
||||
//Columns
|
||||
CanSms: CanSmsColumn,
|
||||
ConfirmedMessageID: ConfirmedMessageIDColumn,
|
||||
ContactID: ContactIDColumn,
|
||||
E164: E164Column,
|
||||
IsSubscribed: IsSubscribedColumn,
|
||||
StopMessageID: StopMessageIDColumn,
|
||||
ID: IDColumn,
|
||||
ContactID: ContactIDColumn,
|
||||
E164: E164Column,
|
||||
IsSubscribed: IsSubscribedColumn,
|
||||
ID: IDColumn,
|
||||
|
||||
AllColumns: allColumns,
|
||||
MutableColumns: mutableColumns,
|
||||
|
|
|
|||
|
|
@ -17,10 +17,10 @@ type phoneTable struct {
|
|||
postgres.Table
|
||||
|
||||
// Columns
|
||||
E164 postgres.ColumnString
|
||||
IsSubscribed postgres.ColumnBool
|
||||
Status postgres.ColumnString
|
||||
CanSms postgres.ColumnBool
|
||||
E164 postgres.ColumnString
|
||||
CanSms postgres.ColumnBool
|
||||
ConfirmedMessageID postgres.ColumnInteger
|
||||
StopMessageID postgres.ColumnInteger
|
||||
|
||||
AllColumns postgres.ColumnList
|
||||
MutableColumns postgres.ColumnList
|
||||
|
|
@ -62,23 +62,23 @@ func newPhoneTable(schemaName, tableName, alias string) *PhoneTable {
|
|||
|
||||
func newPhoneTableImpl(schemaName, tableName, alias string) phoneTable {
|
||||
var (
|
||||
E164Column = postgres.StringColumn("e164")
|
||||
IsSubscribedColumn = postgres.BoolColumn("is_subscribed")
|
||||
StatusColumn = postgres.StringColumn("status")
|
||||
CanSmsColumn = postgres.BoolColumn("can_sms")
|
||||
allColumns = postgres.ColumnList{E164Column, IsSubscribedColumn, StatusColumn, CanSmsColumn}
|
||||
mutableColumns = postgres.ColumnList{IsSubscribedColumn, StatusColumn, CanSmsColumn}
|
||||
defaultColumns = postgres.ColumnList{}
|
||||
E164Column = postgres.StringColumn("e164")
|
||||
CanSmsColumn = postgres.BoolColumn("can_sms")
|
||||
ConfirmedMessageIDColumn = postgres.IntegerColumn("confirmed_message_id")
|
||||
StopMessageIDColumn = postgres.IntegerColumn("stop_message_id")
|
||||
allColumns = postgres.ColumnList{E164Column, CanSmsColumn, ConfirmedMessageIDColumn, StopMessageIDColumn}
|
||||
mutableColumns = postgres.ColumnList{CanSmsColumn, ConfirmedMessageIDColumn, StopMessageIDColumn}
|
||||
defaultColumns = postgres.ColumnList{}
|
||||
)
|
||||
|
||||
return phoneTable{
|
||||
Table: postgres.NewTable(schemaName, tableName, alias, allColumns...),
|
||||
|
||||
//Columns
|
||||
E164: E164Column,
|
||||
IsSubscribed: IsSubscribedColumn,
|
||||
Status: StatusColumn,
|
||||
CanSms: CanSmsColumn,
|
||||
E164: E164Column,
|
||||
CanSms: CanSmsColumn,
|
||||
ConfirmedMessageID: ConfirmedMessageIDColumn,
|
||||
StopMessageID: StopMessageIDColumn,
|
||||
|
||||
AllColumns: allColumns,
|
||||
MutableColumns: mutableColumns,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue