Remove comms.contact_email.id column
The address is the primary key, rather than an ID.
This commit is contained in:
parent
e3cc1e99d1
commit
dcce7cda1c
4 changed files with 7 additions and 12 deletions
|
|
@ -11,6 +11,5 @@ type ContactEmail struct {
|
|||
Address string `sql:"primary_key"`
|
||||
Confirmed bool
|
||||
ContactID int32
|
||||
ID int32
|
||||
IsSubscribed bool
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ type contactEmailTable struct {
|
|||
Address postgres.ColumnString
|
||||
Confirmed postgres.ColumnBool
|
||||
ContactID postgres.ColumnInteger
|
||||
ID postgres.ColumnInteger
|
||||
IsSubscribed postgres.ColumnBool
|
||||
|
||||
AllColumns postgres.ColumnList
|
||||
|
|
@ -66,11 +65,10 @@ func newContactEmailTableImpl(schemaName, tableName, alias string) contactEmailT
|
|||
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}
|
||||
allColumns = postgres.ColumnList{AddressColumn, ConfirmedColumn, ContactIDColumn, IsSubscribedColumn}
|
||||
mutableColumns = postgres.ColumnList{ConfirmedColumn, ContactIDColumn, IsSubscribedColumn}
|
||||
defaultColumns = postgres.ColumnList{}
|
||||
)
|
||||
|
||||
return contactEmailTable{
|
||||
|
|
@ -80,7 +78,6 @@ func newContactEmailTableImpl(schemaName, tableName, alias string) contactEmailT
|
|||
Address: AddressColumn,
|
||||
Confirmed: ConfirmedColumn,
|
||||
ContactID: ContactIDColumn,
|
||||
ID: IDColumn,
|
||||
IsSubscribed: IsSubscribedColumn,
|
||||
|
||||
AllColumns: allColumns,
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import (
|
|||
)
|
||||
|
||||
func ContactEmailInsert(ctx context.Context, txn db.Ex, m model.ContactEmail) (model.ContactEmail, error) {
|
||||
statement := table.ContactEmail.INSERT(table.ContactEmail.MutableColumns).
|
||||
statement := table.ContactEmail.INSERT(table.ContactEmail.AllColumns).
|
||||
MODEL(m).
|
||||
RETURNING(table.ContactEmail.AllColumns)
|
||||
return db.ExecuteOneTx[model.ContactEmail](ctx, txn, statement)
|
||||
|
|
|
|||
|
|
@ -92,10 +92,9 @@ func SaveReporter(ctx context.Context, txn db.Ex, report modelpublicreport.Repor
|
|||
}
|
||||
if email_address != "" {
|
||||
e, err := querycomms.ContactEmailInsert(ctx, txn, modelcomms.ContactEmail{
|
||||
Address: email_address,
|
||||
Confirmed: false,
|
||||
ContactID: contact.ID,
|
||||
//ID
|
||||
Address: email_address,
|
||||
Confirmed: false,
|
||||
ContactID: contact.ID,
|
||||
IsSubscribed: false,
|
||||
})
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue