Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
docker cp database:dump.sql dump.sql

Change the table names and columns

Some tables have been renamed when moving to the new version of the product. In particular SMDevices changed into sm_devices and SMDeviceModels changed into sm_device_models. The dump.sql file need to be updated to reflect that change. This can be done either manually using a proper file editor or with some Linux-style commands such as:

Code Block
languagebash
sed -i 's/SMDevices/sm_devices/g' dump.sql
sed -i 's/SMDeviceModels/sm_device_models/g' dump.sql

The sm_devices table contains a new smrdSecurityId column that needs to be added to the file.

First, update the table creation command to the following:

Code Block
languagebash
DROP TABLE IF EXISTS `sm_devices`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `sm_devices` (
  `smrdId` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Id of the corresponding Devices row.',
  `smrdTerminalId` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Terminal Id.  Used to identify the device within the API',
  `smrdIMEI` varchar(15) COLLATE utf8mb4_unicode_ci NOT NULL COMMENT 'IMEI number of the device',
  `smrdModel` int(11) NOT NULL COMMENT 'Model of the device.',
  `smrdState` int(11) NOT NULL DEFAULT '1' COMMENT 'State of the device.',
  `smrdCreatedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Date and time when the row was created.',
  `smrdUpdatedAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT 'Date and time when the row was last updated.',
  `smrdDeletedAt` datetime DEFAULT NULL COMMENT 'Date and time when the row was deleted.',
  `smrdSecurityId` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'Security ID of the device, unique per hardware unit.',
  PRIMARY KEY (`smrdId`),
  KEY `IXFK_Devices_DeviceModels` (`smrdModel`),
  KEY `FK_sm_devices_SMDeviceStates` (`smrdState`),
  KEY `FK_SMDevices_SMDeviceSecurityIds` (`smrdSecurityId`),
  CONSTRAINT `FK_Devices_DeviceModels` FOREIGN KEY (`smrdModel`) REFERENCES `sm_device_models` (`smdmId`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `FK_sm_devices_SMDeviceStates` FOREIGN KEY (`smrdState`) REFERENCES `SMDeviceStates` (`smdsId`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Registered devices';
/*!40101 SET character_set_client = @saved_cs_client */;

The modification only consists in the addition of lines 13 and 17.

Loading the old database content into the new one

...