From 2453f0568f29b1bc9c30872b843b5e5ace8cccef Mon Sep 17 00:00:00 2001 From: Guillaume Louvigny Date: Mon, 4 Feb 2019 16:29:22 +0100 Subject: [PATCH] fix: missing migration for notifications settings in Config --- core/sql/migrations/list_migrations.go | 10 ++-- .../v0003notificationssettings/migrations.go | 51 +++++++++++++++++++ 2 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 core/sql/migrations/v0003notificationssettings/migrations.go diff --git a/core/sql/migrations/list_migrations.go b/core/sql/migrations/list_migrations.go index 53720ba7a1..cbcef5d0af 100644 --- a/core/sql/migrations/list_migrations.go +++ b/core/sql/migrations/list_migrations.go @@ -3,14 +3,16 @@ package migrations import ( "berty.tech/core/sql/migrations/v0001init" "berty.tech/core/sql/migrations/v0002pushtokens" + "berty.tech/core/sql/migrations/v0003notificationssettings" "github.com/go-gormigrate/gormigrate" ) func GetMigrations() []*gormigrate.Migration { - functions := []*gormigrate.Migration{} + migrations := []*gormigrate.Migration{} - functions = append(functions, v0001init.GetMigration()) - functions = append(functions, v0002pushtokens.GetMigration()) + migrations = append(migrations, v0001init.GetMigration()) + migrations = append(migrations, v0002pushtokens.GetMigration()) + migrations = append(migrations, v0003notificationssettings.GetMigration()) - return functions + return migrations } diff --git a/core/sql/migrations/v0003notificationssettings/migrations.go b/core/sql/migrations/v0003notificationssettings/migrations.go new file mode 100644 index 0000000000..87219b4625 --- /dev/null +++ b/core/sql/migrations/v0003notificationssettings/migrations.go @@ -0,0 +1,51 @@ +package v0003notificationssettings + +import ( + "time" + + "github.com/go-gormigrate/gormigrate" + "github.com/jinzhu/gorm" +) + +type DebugVerbosity int32 + +type Contact struct { + ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` +} + +type Device struct { + ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` +} + +type Config struct { + ID string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty" gorm:"primary_key"` + CreatedAt time.Time `protobuf:"bytes,2,opt,name=created_at,json=createdAt,stdtime" json:"created_at"` + UpdatedAt time.Time `protobuf:"bytes,3,opt,name=updated_at,json=updatedAt,stdtime" json:"updated_at"` + Myself *Contact `protobuf:"bytes,5,opt,name=myself" json:"myself,omitempty"` + MyselfID string `protobuf:"bytes,6,opt,name=myself_id,json=myselfId,proto3" json:"myself_id,omitempty"` + CurrentDevice *Device `protobuf:"bytes,7,opt,name=current_device,json=currentDevice" json:"current_device,omitempty"` + CurrentDeviceID string `protobuf:"bytes,8,opt,name=current_device_id,json=currentDeviceId,proto3" json:"current_device_id,omitempty"` + CryptoParams []byte `protobuf:"bytes,9,opt,name=crypto_params,json=cryptoParams,proto3" json:"crypto_params,omitempty"` + PushRelayPubkeyAPNS string `protobuf:"bytes,10,opt,name=push_relay_pubkey_apns,json=pushRelayPubkeyApns,proto3" json:"push_relay_pubkey_apns,omitempty"` + PushRelayPubkeyFCM string `protobuf:"bytes,11,opt,name=push_relay_pubkey_fcm,json=pushRelayPubkeyFcm,proto3" json:"push_relay_pubkey_fcm,omitempty"` + NotificationsEnabled bool `protobuf:"varint,12,opt,name=notifications_enabled,json=notificationsEnabled,proto3" json:"notifications_enabled,omitempty"` + NotificationsPreviews bool `protobuf:"varint,13,opt,name=notifications_previews,json=notificationsPreviews,proto3" json:"notifications_previews,omitempty"` + DebugNotificationVerbosity DebugVerbosity `protobuf:"varint,14,opt,name=debug_notification_verbosity,json=debugNotificationVerbosity,proto3,enum=berty.entity.DebugVerbosity" json:"debug_notification_verbosity,omitempty"` + XXX_NoUnkeyedLiteral struct{} `json:"-"` + XXX_unrecognized []byte `json:"-"` + XXX_sizecache int32 `json:"-"` +} + +func GetMigration() *gormigrate.Migration { + return &gormigrate.Migration{ + ID: "0003_notifications_settings", + Migrate: func(tx *gorm.DB) error { + return tx.AutoMigrate( + Config{}, + ).Error + }, + Rollback: func(tx *gorm.DB) error { + return nil + }, + } +}