diff --git a/databases.go b/databases.go index 42fe3b0c..ae708a7c 100644 --- a/databases.go +++ b/databases.go @@ -17,6 +17,7 @@ type DatabasesService interface { DatabaseEnableFeature(ctx context.Context, app, addonID, feature string) (DatabaseEnableFeatureResponse, error) DatabaseDisableFeature(ctx context.Context, app, addonID, feature string) (DatabaseDisableFeatureResponse, error) DatabaseUpdatePeriodicBackupsConfig(ctx context.Context, app, addonID string, params DatabaseUpdatePeriodicBackupsConfigParams) (Database, error) + DatabaseUpgrade(ctx context.Context, app, addonID string) error } // DatabaseStatus is a string representing the status of a database deployment @@ -229,3 +230,16 @@ func (c *Client) DatabaseDisableFeature(ctx context.Context, app, addonID, featu return res, nil } + +// DatabaseUpgrade queries the database version upgrade +func (c *Client) DatabaseUpgrade(ctx context.Context, app, addonID string) error { + err := c.DBAPI(app, addonID).DoRequest(ctx, &httpclient.APIRequest{ + Method: "POST", + Endpoint: "/databases/" + addonID + "/upgrade", + Expected: httpclient.Statuses{http.StatusOK}, + }, nil) + if err != nil { + return errgo.Notef(err, "fail to query the database upgrade") + } + return nil +} diff --git a/mocks_sig.json b/mocks_sig.json index 53aedbd5..a61b1b98 100644 --- a/mocks_sig.json +++ b/mocks_sig.json @@ -10,7 +10,7 @@ "github.com/Scalingo/go-scalingo.ContainerSizesService": "e2 db 25 a1 01 52 dc e9 6f 7b f4 59 68 95 86 b9 5e 39 8a 61", "github.com/Scalingo/go-scalingo.ContainersService": "ef 14 ae 81 c9 b4 6a 13 48 e8 bf 44 7d b5 b2 a6 4d e5 02 11", "github.com/Scalingo/go-scalingo.CronTasksService": "9b d9 a3 ca 9f 9a f7 73 cb b1 aa 80 df 90 21 ff 14 92 b4 4d", - "github.com/Scalingo/go-scalingo.DatabasesService": "bf 4d 92 13 a5 11 a5 f6 ad 14 f3 72 81 19 5a 48 65 1e b1 90", + "github.com/Scalingo/go-scalingo.DatabasesService": "9e 31 e4 5d a4 eb d9 7d 49 88 57 04 ce 00 ba d4 74 bd 70 58", "github.com/Scalingo/go-scalingo.DeploymentsService": "aa b5 25 87 ff f0 d2 9f 3a 32 42 2d d6 02 33 5f 63 14 2b 9a", "github.com/Scalingo/go-scalingo.DomainsService": "2f 49 a8 58 f3 ae 8c 4d 4d 6b 1f 47 fc dc db b3 d0 84 ba de", "github.com/Scalingo/go-scalingo.EventsService": "29 cf 29 33 fb 33 ce 86 3b 49 db ae 25 2d 5d 22 d6 60 21 95", diff --git a/scalingomock/api_mock.go b/scalingomock/api_mock.go index 7e9925a5..9d0bc0b4 100644 --- a/scalingomock/api_mock.go +++ b/scalingomock/api_mock.go @@ -765,6 +765,20 @@ func (mr *MockAPIMockRecorder) DatabaseUpdatePeriodicBackupsConfig(arg0, arg1, a return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DatabaseUpdatePeriodicBackupsConfig", reflect.TypeOf((*MockAPI)(nil).DatabaseUpdatePeriodicBackupsConfig), arg0, arg1, arg2, arg3) } +// DatabaseUpgrade mocks base method. +func (m *MockAPI) DatabaseUpgrade(arg0 context.Context, arg1, arg2 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DatabaseUpgrade", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// DatabaseUpgrade indicates an expected call of DatabaseUpgrade. +func (mr *MockAPIMockRecorder) DatabaseUpgrade(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DatabaseUpgrade", reflect.TypeOf((*MockAPI)(nil).DatabaseUpgrade), arg0, arg1, arg2) +} + // Deployment mocks base method. func (m *MockAPI) Deployment(arg0 context.Context, arg1, arg2 string) (*scalingo.Deployment, error) { m.ctrl.T.Helper() diff --git a/scalingomock/databasesservice_mock.go b/scalingomock/databasesservice_mock.go index ef1aa6ee..5caf5958 100644 --- a/scalingomock/databasesservice_mock.go +++ b/scalingomock/databasesservice_mock.go @@ -94,3 +94,17 @@ func (mr *MockDatabasesServiceMockRecorder) DatabaseUpdatePeriodicBackupsConfig( mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DatabaseUpdatePeriodicBackupsConfig", reflect.TypeOf((*MockDatabasesService)(nil).DatabaseUpdatePeriodicBackupsConfig), arg0, arg1, arg2, arg3) } + +// DatabaseUpgrade mocks base method. +func (m *MockDatabasesService) DatabaseUpgrade(arg0 context.Context, arg1, arg2 string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DatabaseUpgrade", arg0, arg1, arg2) + ret0, _ := ret[0].(error) + return ret0 +} + +// DatabaseUpgrade indicates an expected call of DatabaseUpgrade. +func (mr *MockDatabasesServiceMockRecorder) DatabaseUpgrade(arg0, arg1, arg2 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DatabaseUpgrade", reflect.TypeOf((*MockDatabasesService)(nil).DatabaseUpgrade), arg0, arg1, arg2) +}