/
migration.go
37 lines (32 loc) · 1.94 KB
/
migration.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package v0007eventdispatchretry
import (
"time"
"github.com/jinzhu/gorm"
gormigrate "gopkg.in/gormigrate.v1"
)
type EventDispatch_Medium int32
type EventDispatch struct {
EventID string `protobuf:"bytes,1,opt,name=event_id,json=eventId,proto3" json:"event_id,omitempty" gorm:"primary_key"`
DeviceID string `protobuf:"bytes,2,opt,name=device_id,json=deviceId,proto3" json:"device_id,omitempty" gorm:"primary_key"`
ContactID string `protobuf:"bytes,3,opt,name=contact_id,json=contactId,proto3" json:"contact_id,omitempty"`
SentAt *time.Time `protobuf:"bytes,4,opt,name=sent_at,json=sentAt,proto3,stdtime" json:"sent_at,omitempty"`
AckedAt *time.Time `protobuf:"bytes,5,opt,name=acked_at,json=ackedAt,proto3,stdtime" json:"acked_at,omitempty"`
SeenAt *time.Time `protobuf:"bytes,6,opt,name=seen_at,json=seenAt,proto3,stdtime" json:"seen_at,omitempty"`
AckMedium EventDispatch_Medium `protobuf:"varint,7,opt,name=ack_medium,json=ackMedium,proto3,enum=berty.entity.EventDispatch_Medium" json:"ack_medium,omitempty"`
SeenMedium EventDispatch_Medium `protobuf:"varint,8,opt,name=seen_medium,json=seenMedium,proto3,enum=berty.entity.EventDispatch_Medium" json:"seen_medium,omitempty"`
RetryBackoff int64 `protobuf:"varint,9,opt,name=retry_backoff,json=retryBackoff,proto3" json:"retry_backoff,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
XXX_sizecache int32 `json:"-"`
}
func GetMigration() *gormigrate.Migration {
return &gormigrate.Migration{
ID: "0007_event_dispatch_retry",
Migrate: func(tx *gorm.DB) error {
return tx.AutoMigrate(&EventDispatch{}).Error
},
Rollback: func(tx *gorm.DB) error {
return tx.Table("event_dispatch").DropColumn("retry_backoff").Error
},
}
}