Add admin and customer interfaces, orders, signed activation and leases, protected package delivery, keyring verification, migrations, security controls, tests and deployment documentation. Co-Authored-By: Craft Agent <agents-noreply@craft.do>
36 lines
1.8 KiB
SQL
36 lines
1.8 KiB
SQL
ALTER TABLE license_instances
|
|
ADD COLUMN last_seen_at TIMESTAMP(6) NULL,
|
|
ADD COLUMN client_seen_at TIMESTAMP(6) NULL,
|
|
ADD COLUMN observed_state VARCHAR(32) NOT NULL DEFAULT 'unknown',
|
|
ADD COLUMN lease_expires_at TIMESTAMP(6) NULL,
|
|
ADD COLUMN freeze_state VARCHAR(32) NOT NULL DEFAULT 'none',
|
|
ADD KEY idx_license_instances_last_seen (last_seen_at),
|
|
ADD KEY idx_license_instances_lease (lease_expires_at);
|
|
|
|
CREATE TABLE heartbeat_operations (
|
|
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
instance_id BIGINT UNSIGNED NOT NULL,
|
|
idempotency_key VARCHAR(128) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
request_fingerprint BINARY(32) NOT NULL,
|
|
response JSON NOT NULL,
|
|
state VARCHAR(32) NOT NULL,
|
|
created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY uq_heartbeat_operations_key (instance_id, idempotency_key),
|
|
CONSTRAINT fk_heartbeat_operations_instance FOREIGN KEY (instance_id) REFERENCES license_instances(id) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
|
|
CREATE TABLE instance_state_operations (
|
|
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
instance_id BIGINT UNSIGNED NOT NULL,
|
|
actor_admin_id BIGINT UNSIGNED NOT NULL,
|
|
idempotency_key VARCHAR(128) CHARACTER SET ascii COLLATE ascii_bin NOT NULL,
|
|
request_fingerprint BINARY(32) NOT NULL,
|
|
response JSON NOT NULL,
|
|
created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY uq_instance_state_operations_key (actor_admin_id,idempotency_key),
|
|
CONSTRAINT fk_instance_state_operations_instance FOREIGN KEY (instance_id) REFERENCES license_instances(id),
|
|
CONSTRAINT fk_instance_state_operations_admin FOREIGN KEY (actor_admin_id) REFERENCES admins(id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|