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

mendersoftware / mender-server / 1592525883

17 Dec 2024 01:50PM UTC coverage: 73.526% (+0.7%) from 72.839%
1592525883

Pull #270

gitlab-ci

bahaa-ghazal
test: testing 'deploy to all devices' feature

Changelog = Title
Ticket = MEN-4272
Signed-off-by: Bahaa Aldeen Ghazal <bahaa.ghazal@northern.tech>
Pull Request #270: test: testing 'deploy to all devices' feature

4244 of 6144 branches covered (69.08%)

Branch coverage included in aggregate %.

40043 of 54089 relevant lines covered (74.03%)

23.11 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✔
62
                return errors.Wrap(err, "failed to apply migrations")
×
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