• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / mender-server / 1704099547

06 Mar 2025 04:08PM UTC coverage: 65.477% (-0.03%) from 65.502%
1704099547

push

gitlab-ci

web-flow
Merge pull request #506 from merlin-northern/men_7868_iot_manager_service_stores_deviceauth_related_events_even_if_no_integration_is_configured_

fix(iot-manager): do not store events if there are no integrations.

9 of 9 new or added lines in 1 file covered. (100.0%)

18 existing lines in 5 files now uncovered.

31645 of 48330 relevant lines covered (65.48%)

1.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.19
/backend/services/workflows/store/mongo/migrations.go
1
// Copyright 2021 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14

15
package mongo
16

17
import (
18
        "context"
19

20
        "github.com/pkg/errors"
21
        "go.mongodb.org/mongo-driver/mongo"
22

23
        "github.com/mendersoftware/mender-server/pkg/log"
24
        "github.com/mendersoftware/mender-server/pkg/mongo/migrate"
25
)
26

27
const (
28
        // DbVersion is the current schema version
29
        DbVersion = "1.0.0"
30
)
31

32
// Migrate applies migrations to the database
33
func Migrate(ctx context.Context,
34
        db string,
35
        version string,
36
        client *mongo.Client,
37
        automigrate bool) error {
3✔
38
        l := log.FromContext(ctx)
3✔
39

3✔
40
        l.Infof("migrating %s", db)
3✔
41

3✔
42
        ver, err := migrate.NewVersion(version)
3✔
43
        if err != nil {
3✔
44
                return errors.Wrap(err, "failed to parse service version")
×
45
        }
×
46

47
        m := migrate.SimpleMigrator{
3✔
48
                Client:      client,
3✔
49
                Db:          db,
3✔
50
                Automigrate: automigrate,
3✔
51
        }
3✔
52

3✔
53
        migrations := []migrate.Migration{
3✔
54
                &migration1_0_0{
3✔
55
                        client: client,
3✔
56
                        db:     db,
3✔
57
                },
3✔
58
        }
3✔
59

3✔
60
        err = m.Apply(ctx, *ver, migrations)
3✔
61
        if err != nil {
3✔
UNCOV
62
                return errors.Wrap(err, "failed to apply migrations")
×
UNCOV
63
        }
×
64

65
        return nil
3✔
66
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc