|
| 1 | +-- +migrate Up |
| 2 | +-- SQL in section 'Up' is executed when this migration is applied |
| 3 | + |
| 4 | +-- The orders2 table holds one row per ACME Order object. The authorizations |
| 5 | +-- column contains an opaque JSON blob which the SA can use to find the |
| 6 | +-- associated authorizations without requiring db-level foreign keys. Most |
| 7 | +-- orders are created with status "pending", but may be created with status |
| 8 | +-- "ready" if all of their authorizations are reused and already valid. Orders |
| 9 | +-- transition to status "processing" when finalization begins. The error field |
| 10 | +-- is populated only if an error occurs during finalization and the order moves |
| 11 | +-- to the "invalid" state; errors during validation are reflected elsewhere. |
| 12 | +CREATE TABLE `orders2` ( |
| 13 | + `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
| 14 | + `registrationID` bigint(20) NOT NULL, |
| 15 | + `created` datetime NOT NULL, |
| 16 | + `expires` datetime NOT NULL, |
| 17 | + `authorizations` json NOT NULL, |
| 18 | + `profile` varchar(255) NOT NULL, |
| 19 | + `status` tinyint(4) NOT NULL, |
| 20 | + `error` mediumblob DEFAULT NULL, |
| 21 | + `certificateSerial` varchar(255) DEFAULT NULL, |
| 22 | + PRIMARY KEY (`id`), |
| 23 | + KEY `reg_status_expires` (`registrationID`,`expires`), |
| 24 | + KEY `regID_created_idx` (`registrationID`,`created`) |
| 25 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
| 26 | + PARTITION BY RANGE(id) |
| 27 | +(PARTITION p_start VALUES LESS THAN (MAXVALUE)); |
| 28 | + |
| 29 | +-- The authorizations table holds one row per ACME Authorization object and |
| 30 | +-- associated challenges. It is always created with status "pending". After |
| 31 | +-- one of its challenges is attempted, it will transition into either status |
| 32 | +-- "valid" or "invalid", and the validations column will be updated to point |
| 33 | +-- to a new row in the validations table containing the record of that attempt. |
| 34 | +CREATE TABLE `authorizations` ( |
| 35 | + `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
| 36 | + `registrationID` bigint(20) NOT NULL, |
| 37 | + `identifierType` tinyint(4) NOT NULL, |
| 38 | + `identifierValue` varchar(255) NOT NULL, |
| 39 | + `created` datetime NOT NULL, |
| 40 | + `expires` datetime NOT NULL, |
| 41 | + `profile` varchar(255) NOT NULL, |
| 42 | + `challenges` tinyint(4) NOT NULL, |
| 43 | + `token` binary(32) NOT NULL, |
| 44 | + `status` tinyint(4) NOT NULL, |
| 45 | + `validations` json DEFAULT NULL, |
| 46 | + PRIMARY KEY (`id`), |
| 47 | + KEY `regID_expires_idx` (`registrationID`,`status`,`expires`), |
| 48 | + KEY `regID_identifier_status_expires_idx` (`registrationID`,`identifierType`,`identifierValue`,`status`,`expires`), |
| 49 | + KEY `expires_idx` (`expires`) |
| 50 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
| 51 | + PARTITION BY RANGE(id) |
| 52 | +(PARTITION p_start VALUES LESS THAN (MAXVALUE)); |
| 53 | + |
| 54 | +-- The validations table holds records of completed validation attempts, |
| 55 | +-- including the validation method used, the resulting status (valid or |
| 56 | +-- invalid), and an opaque blob of our audit record. |
| 57 | +CREATE TABLE `validations` ( |
| 58 | + `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, |
| 59 | + `challenge` tinyint(4) NOT NULL, |
| 60 | + `attemptedAt` datetime NOT NULL, |
| 61 | + `status` tinyint(4) NOT NULL, |
| 62 | + `record` json DEFAULT NULL, |
| 63 | +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 |
| 64 | + PARTITION BY RANGE(id) |
| 65 | +(PARTITION p_start VALUES LESS THAN (MAXVALUE)); |
| 66 | + |
| 67 | +-- +migrate Down |
| 68 | +-- SQL section 'Down' is executed when this migration is rolled back |
| 69 | + |
| 70 | +DROP TABLE `validations`; |
| 71 | +DROP TABLE `authorizations`; |
| 72 | +DROP TABLE `orders2`; |
0 commit comments