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"`
|
Address string `sql:"primary_key"`
|
||||||
Confirmed bool
|
Confirmed bool
|
||||||
ContactID int32
|
ContactID int32
|
||||||
ID int32
|
|
||||||
IsSubscribed bool
|
IsSubscribed bool
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ type contactEmailTable struct {
|
||||||
Address postgres.ColumnString
|
Address postgres.ColumnString
|
||||||
Confirmed postgres.ColumnBool
|
Confirmed postgres.ColumnBool
|
||||||
ContactID postgres.ColumnInteger
|
ContactID postgres.ColumnInteger
|
||||||
ID postgres.ColumnInteger
|
|
||||||
IsSubscribed postgres.ColumnBool
|
IsSubscribed postgres.ColumnBool
|
||||||
|
|
||||||
AllColumns postgres.ColumnList
|
AllColumns postgres.ColumnList
|
||||||
|
|
@ -66,11 +65,10 @@ func newContactEmailTableImpl(schemaName, tableName, alias string) contactEmailT
|
||||||
AddressColumn = postgres.StringColumn("address")
|
AddressColumn = postgres.StringColumn("address")
|
||||||
ConfirmedColumn = postgres.BoolColumn("confirmed")
|
ConfirmedColumn = postgres.BoolColumn("confirmed")
|
||||||
ContactIDColumn = postgres.IntegerColumn("contact_id")
|
ContactIDColumn = postgres.IntegerColumn("contact_id")
|
||||||
IDColumn = postgres.IntegerColumn("id")
|
|
||||||
IsSubscribedColumn = postgres.BoolColumn("is_subscribed")
|
IsSubscribedColumn = postgres.BoolColumn("is_subscribed")
|
||||||
allColumns = postgres.ColumnList{AddressColumn, ConfirmedColumn, ContactIDColumn, IDColumn, IsSubscribedColumn}
|
allColumns = postgres.ColumnList{AddressColumn, ConfirmedColumn, ContactIDColumn, IsSubscribedColumn}
|
||||||
mutableColumns = postgres.ColumnList{ConfirmedColumn, ContactIDColumn, IDColumn, IsSubscribedColumn}
|
mutableColumns = postgres.ColumnList{ConfirmedColumn, ContactIDColumn, IsSubscribedColumn}
|
||||||
defaultColumns = postgres.ColumnList{IDColumn}
|
defaultColumns = postgres.ColumnList{}
|
||||||
)
|
)
|
||||||
|
|
||||||
return contactEmailTable{
|
return contactEmailTable{
|
||||||
|
|
@ -80,7 +78,6 @@ func newContactEmailTableImpl(schemaName, tableName, alias string) contactEmailT
|
||||||
Address: AddressColumn,
|
Address: AddressColumn,
|
||||||
Confirmed: ConfirmedColumn,
|
Confirmed: ConfirmedColumn,
|
||||||
ContactID: ContactIDColumn,
|
ContactID: ContactIDColumn,
|
||||||
ID: IDColumn,
|
|
||||||
IsSubscribed: IsSubscribedColumn,
|
IsSubscribed: IsSubscribedColumn,
|
||||||
|
|
||||||
AllColumns: allColumns,
|
AllColumns: allColumns,
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func ContactEmailInsert(ctx context.Context, txn db.Ex, m model.ContactEmail) (model.ContactEmail, error) {
|
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).
|
MODEL(m).
|
||||||
RETURNING(table.ContactEmail.AllColumns)
|
RETURNING(table.ContactEmail.AllColumns)
|
||||||
return db.ExecuteOneTx[model.ContactEmail](ctx, txn, statement)
|
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 != "" {
|
if email_address != "" {
|
||||||
e, err := querycomms.ContactEmailInsert(ctx, txn, modelcomms.ContactEmail{
|
e, err := querycomms.ContactEmailInsert(ctx, txn, modelcomms.ContactEmail{
|
||||||
Address: email_address,
|
Address: email_address,
|
||||||
Confirmed: false,
|
Confirmed: false,
|
||||||
ContactID: contact.ID,
|
ContactID: contact.ID,
|
||||||
//ID
|
|
||||||
IsSubscribed: false,
|
IsSubscribed: false,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue