|
46 | 46 | migrateDevices bool |
47 | 47 | migrateGatewayMetrics bool |
48 | 48 | migrateDeviceMetrics bool |
| 49 | + disableMigratedDevices bool |
49 | 50 | ) |
50 | 51 |
|
51 | 52 | // Internal state |
@@ -92,6 +93,7 @@ func init() { |
92 | 93 | rootCmd.PersistentFlags().StringArrayVarP(&nsConfigFiles, "ns-config-file", "", []string{}, "Path to chirpstack-network-server.toml configuration file (can be repeated)") |
93 | 94 | rootCmd.PersistentFlags().StringVarP(&devEUIListFile, "deveui-list-file", "", "", "Path to file containing DevEUIs to migrate (one DevEUI per line)") |
94 | 95 | rootCmd.PersistentFlags().StringVarP(&deviceProfileIDListFile, "device-profile-id-list-file", "", "", "Path to file containing list of Device Profile IDs to migrate (one per line)") |
| 96 | + rootCmd.PersistentFlags().BoolVarP(&disableMigratedDevices, "disable-migrated-devices", "", false, "Disable migrated devices in ChirpStack v3") |
95 | 97 | rootCmd.PersistentFlags().IntVarP(&csSessionTTL, "device-session-ttl-days", "", 31, "Device-session TTL in days") |
96 | 98 | rootCmd.PersistentFlags().BoolVarP(&dropTenantAndUsers, "drop-tenants-and-users", "", false, "Drop tenants and users before migration") |
97 | 99 | rootCmd.PersistentFlags().BoolVarP(&migrateUsers, "migrate-users", "", true, "Migrate users") |
@@ -1585,6 +1587,14 @@ func migrateDevicesFn() { |
1585 | 1587 | for devEUI := range appSKeys { |
1586 | 1588 | migrateDeviceGatewayFn(devEUI[:]) |
1587 | 1589 | } |
| 1590 | + |
| 1591 | + if disableMigratedDevices { |
| 1592 | + log.Println("Disable migrated devices") |
| 1593 | + _, err := nsDB.Exec("update device set is_disabled = true where dev_eui = any($1)", pq.ByteaArray(deviceIDs)) |
| 1594 | + if err != nil { |
| 1595 | + log.Fatal("Disable migrated devices error", err) |
| 1596 | + } |
| 1597 | + } |
1588 | 1598 | } |
1589 | 1599 |
|
1590 | 1600 | func migrateDeviceKeysFn(tx *sqlx.Tx, devEUIs [][]byte) { |
|
0 commit comments