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.
26 lines
889 B
Go
26 lines
889 B
Go
package publicreport
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/Gleipnir-Technology/nidus-sync/db"
|
|
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/publicreport/model"
|
|
"github.com/Gleipnir-Technology/nidus-sync/db/gen/nidus-sync/publicreport/table"
|
|
//"github.com/Gleipnir-Technology/jet/postgres"
|
|
)
|
|
|
|
func NotifyPhoneInsert(ctx context.Context, txn db.Ex, m model.NotifyPhone) (model.NotifyPhone, error) {
|
|
statement := table.NotifyPhone.INSERT(table.NotifyPhone.MutableColumns).
|
|
MODEL(m).
|
|
RETURNING(table.NotifyPhone.AllColumns)
|
|
return db.ExecuteOneTx[model.NotifyPhone](ctx, txn, statement)
|
|
}
|
|
func NotifyPhoneCreate(ctx context.Context, txn db.Ex, report_id int32, destination string) (model.NotifyPhone, error) {
|
|
return NotifyPhoneInsert(ctx, txn, model.NotifyPhone{
|
|
Created: time.Now(),
|
|
Deleted: nil,
|
|
PhoneE164: destination,
|
|
ReportID: report_id,
|
|
})
|
|
}
|