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>
40 lines
2.0 KiB
SQL
40 lines
2.0 KiB
SQL
CREATE TABLE license_instances (
|
|
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,
|
|
instance_id CHAR(36) NOT NULL,
|
|
license_id BIGINT UNSIGNED NOT NULL,
|
|
customer_id BIGINT UNSIGNED NOT NULL,
|
|
product_id BIGINT UNSIGNED NOT NULL,
|
|
secret_hash BINARY(32) NOT NULL,
|
|
status VARCHAR(32) NOT NULL DEFAULT 'provisioned',
|
|
activated_at TIMESTAMP(6) NULL,
|
|
certificate_version VARCHAR(32) NULL,
|
|
certificate_payload JSON NULL,
|
|
certificate_signature TEXT NULL,
|
|
created_by BIGINT UNSIGNED NOT NULL,
|
|
created_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
|
|
updated_at TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
|
|
PRIMARY KEY (id),
|
|
UNIQUE KEY uq_license_instances_instance (instance_id),
|
|
UNIQUE KEY uq_license_instances_license (license_id),
|
|
KEY idx_license_instances_customer (customer_id),
|
|
KEY idx_license_instances_product (product_id),
|
|
CONSTRAINT fk_license_instances_license FOREIGN KEY (license_id) REFERENCES licenses(id),
|
|
CONSTRAINT fk_license_instances_customer FOREIGN KEY (customer_id) REFERENCES customers(id),
|
|
CONSTRAINT fk_license_instances_product FOREIGN KEY (product_id) REFERENCES products(id),
|
|
CONSTRAINT fk_license_instances_admin FOREIGN KEY (created_by) REFERENCES admins(id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|
|
|
|
CREATE TABLE activation_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_activation_operations_key (instance_id, idempotency_key),
|
|
CONSTRAINT fk_activation_operations_instance FOREIGN KEY (instance_id) REFERENCES license_instances(id),
|
|
CONSTRAINT fk_activation_operations_admin FOREIGN KEY (actor_admin_id) REFERENCES admins(id)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
|