1.0.623.sql 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. -- Apply after unified Raw, dataset release and purchase handoff migrations.
  2. CREATE TABLE IF NOT EXISTS mdp_edge_device (
  3. device_id CHAR(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL PRIMARY KEY,
  4. tenant_id BIGINT NOT NULL, factory_id BIGINT NOT NULL, dataset_id BIGINT NOT NULL, source_id BIGINT NOT NULL,
  5. device_name VARCHAR(120) NOT NULL,
  6. state VARCHAR(16) NOT NULL,
  7. active_slot TINYINT NULL,
  8. activation_hash CHAR(64) CHARACTER SET ascii COLLATE ascii_bin NULL,
  9. activation_expires DATETIME(6) NULL,
  10. certificate_hash CHAR(64) CHARACTER SET ascii COLLATE ascii_bin NULL,
  11. certificate_expires DATETIME(6) NULL,
  12. next_certificate_hash CHAR(64) CHARACTER SET ascii COLLATE ascii_bin NULL,
  13. next_certificate_expires DATETIME(6) NULL,
  14. config_generation BIGINT NOT NULL DEFAULT 0,
  15. config_json JSON NULL, position_text MEDIUMTEXT NULL, task_phase VARCHAR(16) NULL,
  16. seen_at DATETIME(6) NULL, report_json JSON NULL,
  17. page_count INT NOT NULL DEFAULT 0, row_count BIGINT NOT NULL DEFAULT 0,
  18. created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  19. UNIQUE KEY uk_edge_binding (tenant_id,factory_id,dataset_id,source_id,active_slot),
  20. UNIQUE KEY uk_edge_activation (activation_hash),
  21. UNIQUE KEY uk_edge_certificate (certificate_hash),
  22. UNIQUE KEY uk_edge_pending_certificate (next_certificate_hash),
  23. KEY ix_edge_devices (tenant_id,factory_id,dataset_id)
  24. ) ENGINE=InnoDB;
  25. CREATE TABLE IF NOT EXISTS mdp_edge_receipt (
  26. batch_id CHAR(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL PRIMARY KEY,
  27. device_id CHAR(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
  28. tenant_id BIGINT NOT NULL, factory_id BIGINT NOT NULL, dataset_id BIGINT NOT NULL, source_id BIGINT NOT NULL,
  29. generation BIGINT NOT NULL, idem_key VARBINARY(128) NOT NULL,
  30. digest CHAR(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
  31. position_hash CHAR(64) CHARACTER SET ascii COLLATE ascii_bin NULL,
  32. receipt_json JSON NOT NULL, created_at DATETIME(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
  33. KEY ix_edge_receipt_position (device_id,generation,position_hash),
  34. KEY ix_edge_receipt_binding (tenant_id,factory_id,dataset_id,source_id,created_at)
  35. ) ENGINE=InnoDB;
  36. -- Recovery records reference the existing Raw batch and device.
  37. CREATE TABLE IF NOT EXISTS mdp_edge_api_rejected_page (
  38. batch_id CHAR(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL PRIMARY KEY,
  39. device_id CHAR(36) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
  40. generation BIGINT NOT NULL,
  41. position_hash CHAR(64) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
  42. effective_url VARCHAR(2048) NULL, next_link VARCHAR(2048) NULL, link_diagnostic VARCHAR(80) NULL,
  43. settlement VARCHAR(16) NULL, response_path VARCHAR(112) NULL, settled_at DATETIME(6) NULL,
  44. KEY ix_edge_api_reject_position (device_id,generation,position_hash),
  45. KEY ix_edge_api_reject_settlement (device_id,settled_at)
  46. ) ENGINE=InnoDB;