mirror of
https://github.com/outbackdingo/labca.git
synced 2026-01-27 18:19:33 +00:00
252 lines
9.2 KiB
Diff
252 lines
9.2 KiB
Diff
diff --git a/sa/_db/migrations/20210223140000_CombinedSchema.sql b/sa/_db/migrations/20210223140000_CombinedSchema.sql
|
|
index f9705d018..035c5009f 100644
|
|
--- a/sa/_db/migrations/20210223140000_CombinedSchema.sql
|
|
+++ b/sa/_db/migrations/20210223140000_CombinedSchema.sql
|
|
@@ -1,7 +1,9 @@
|
|
-- +goose Up
|
|
-- SQL in section 'Up' is executed when this migration is applied
|
|
|
|
-CREATE TABLE `authz2` (
|
|
+DROP TABLE IF EXISTS `authz`;
|
|
+
|
|
+CREATE TABLE IF NOT EXISTS `authz2` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`identifierType` tinyint(4) NOT NULL,
|
|
`identifierValue` varchar(255) NOT NULL,
|
|
@@ -21,7 +23,7 @@ CREATE TABLE `authz2` (
|
|
KEY `expires_idx` (`expires`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `blockedKeys` (
|
|
+CREATE TABLE IF NOT EXISTS `blockedKeys` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`keyHash` binary(32) NOT NULL,
|
|
`added` datetime NOT NULL,
|
|
@@ -34,7 +36,7 @@ CREATE TABLE `blockedKeys` (
|
|
KEY `extantCertificatesChecked_idx` (`extantCertificatesChecked`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `certificateStatus` (
|
|
+CREATE TABLE IF NOT EXISTS `certificateStatus` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`serial` varchar(255) NOT NULL,
|
|
`subscriberApproved` tinyint(1) DEFAULT 0,
|
|
@@ -54,7 +56,7 @@ CREATE TABLE `certificateStatus` (
|
|
KEY `notAfter_idx` (`notAfter`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `certificatesPerName` (
|
|
+CREATE TABLE IF NOT EXISTS `certificatesPerName` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`eTLDPlusOne` varchar(255) NOT NULL,
|
|
`time` datetime NOT NULL,
|
|
@@ -63,14 +65,24 @@ CREATE TABLE `certificatesPerName` (
|
|
UNIQUE KEY `eTLDPlusOne_time_idx` (`eTLDPlusOne`,`time`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `crls` (
|
|
- `serial` varchar(255) NOT NULL,
|
|
- `createdAt` datetime NOT NULL,
|
|
- `crl` varchar(255) NOT NULL,
|
|
- PRIMARY KEY (`serial`)
|
|
+CREATE TABLE IF NOT EXISTS `challenges` (
|
|
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
+ `authorizationID` varchar(255) NOT NULL,
|
|
+ `LockCol` bigint(20) DEFAULT NULL,
|
|
+ `type` varchar(255) NOT NULL,
|
|
+ `status` varchar(255) NOT NULL,
|
|
+ `error` mediumblob DEFAULT NULL,
|
|
+ `validated` datetime DEFAULT NULL,
|
|
+ `token` varchar(255) NOT NULL,
|
|
+ `validationRecord` mediumblob DEFAULT NULL,
|
|
+ `keyAuthorization` varchar(255) DEFAULT NULL,
|
|
+ PRIMARY KEY (`id`),
|
|
+ KEY `authorizationID_challenges_idx` (`authorizationID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `fqdnSets` (
|
|
+DROP TABLE IF EXISTS `crls`;
|
|
+
|
|
+CREATE TABLE IF NOT EXISTS `fqdnSets` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`setHash` binary(32) NOT NULL,
|
|
`serial` varchar(255) NOT NULL,
|
|
@@ -81,7 +93,7 @@ CREATE TABLE `fqdnSets` (
|
|
KEY `setHash_issued_idx` (`setHash`,`issued`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `issuedNames` (
|
|
+CREATE TABLE IF NOT EXISTS `issuedNames` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`reversedName` varchar(640) CHARACTER SET ascii NOT NULL,
|
|
`notBefore` datetime NOT NULL,
|
|
@@ -92,7 +104,7 @@ CREATE TABLE `issuedNames` (
|
|
KEY `reversedName_renewal_notBefore_Idx` (`reversedName`,`renewal`,`notBefore`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `keyHashToSerial` (
|
|
+CREATE TABLE IF NOT EXISTS `keyHashToSerial` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`keyHash` binary(32) NOT NULL,
|
|
`certNotAfter` datetime NOT NULL,
|
|
@@ -102,7 +114,7 @@ CREATE TABLE `keyHashToSerial` (
|
|
KEY `keyHash_certNotAfter` (`keyHash`,`certNotAfter`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `newOrdersRL` (
|
|
+CREATE TABLE IF NOT EXISTS `newOrdersRL` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`regID` bigint(20) NOT NULL,
|
|
`time` datetime NOT NULL,
|
|
@@ -111,14 +123,16 @@ CREATE TABLE `newOrdersRL` (
|
|
UNIQUE KEY `regID_time_idx` (`regID`,`time`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `orderToAuthz2` (
|
|
+DROP TABLE IF EXISTS `orderToAuthz`;
|
|
+
|
|
+CREATE TABLE IF NOT EXISTS `orderToAuthz2` (
|
|
`orderID` bigint(20) NOT NULL,
|
|
`authzID` bigint(20) NOT NULL,
|
|
PRIMARY KEY (`orderID`,`authzID`),
|
|
KEY `authzID` (`authzID`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `orders` (
|
|
+CREATE TABLE IF NOT EXISTS `orders` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`registrationID` bigint(20) NOT NULL,
|
|
`expires` datetime NOT NULL,
|
|
@@ -131,7 +145,9 @@ CREATE TABLE `orders` (
|
|
KEY `regID_created_idx` (`registrationID`,`created`)
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `registrations` (
|
|
+DROP TABLE IF EXISTS `pendingAuthorizations`;
|
|
+
|
|
+CREATE TABLE IF NOT EXISTS `registrations` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`jwk` mediumblob NOT NULL,
|
|
`jwk_sha256` varchar(255) NOT NULL,
|
|
@@ -148,7 +164,7 @@ CREATE TABLE `registrations` (
|
|
|
|
-- Tables below have foreign key constraints, so are created after all other tables.
|
|
|
|
-CREATE TABLE `certificates` (
|
|
+CREATE TABLE IF NOT EXISTS `certificates` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`registrationID` bigint(20) NOT NULL,
|
|
`serial` varchar(255) NOT NULL,
|
|
@@ -163,7 +179,7 @@ CREATE TABLE `certificates` (
|
|
CONSTRAINT `regId_certificates` FOREIGN KEY (`registrationID`) REFERENCES `registrations` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `orderFqdnSets` (
|
|
+CREATE TABLE IF NOT EXISTS `orderFqdnSets` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`setHash` binary(32) NOT NULL,
|
|
`orderID` bigint(20) NOT NULL,
|
|
@@ -177,7 +193,7 @@ CREATE TABLE `orderFqdnSets` (
|
|
CONSTRAINT `orderFqdnSets_registrationID_registrations` FOREIGN KEY (`registrationID`) REFERENCES `registrations` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `precertificates` (
|
|
+CREATE TABLE IF NOT EXISTS `precertificates` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`registrationID` bigint(20) NOT NULL,
|
|
`serial` varchar(255) NOT NULL,
|
|
@@ -191,7 +207,7 @@ CREATE TABLE `precertificates` (
|
|
CONSTRAINT `regId_precertificates` FOREIGN KEY (`registrationID`) REFERENCES `registrations` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `requestedNames` (
|
|
+CREATE TABLE IF NOT EXISTS `requestedNames` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`orderID` bigint(20) NOT NULL,
|
|
`reversedName` varchar(253) CHARACTER SET ascii NOT NULL,
|
|
@@ -201,7 +217,9 @@ CREATE TABLE `requestedNames` (
|
|
CONSTRAINT `orderID_orders` FOREIGN KEY (`orderID`) REFERENCES `orders` (`id`) ON DELETE CASCADE
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-CREATE TABLE `serials` (
|
|
+DROP TABLE IF EXISTS `sctReceipts`;
|
|
+
|
|
+CREATE TABLE IF NOT EXISTS `serials` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`registrationID` bigint(20) NOT NULL,
|
|
`serial` varchar(255) NOT NULL,
|
|
@@ -223,15 +241,71 @@ DROP TABLE `precertificates`
|
|
DROP TABLE `requestedNames`
|
|
DROP TABLE `serials`
|
|
|
|
+CREATE TABLE `authz` (
|
|
+ `id` varchar(255) NOT NULL,
|
|
+ `identifier` varchar(255) NOT NULL,
|
|
+ `registrationID` bigint(20) NOT NULL,
|
|
+ `status` varchar(255) NOT NULL,
|
|
+ `expires` datetime DEFAULT NULL,
|
|
+ `combinations` varchar(255) NOT NULL,
|
|
+ PRIMARY KEY (`id`),
|
|
+ KEY `registrationID_identifier_status_expires_authz_idx` (`registrationID`,`identifier`,`status`,`expires`),
|
|
+ CONSTRAINT `regId_authz` FOREIGN KEY (`registrationID`) REFERENCES `registrations` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
+
|
|
DROP TABLE `authz2`
|
|
DROP TABLE `blockedKeys`
|
|
DROP TABLE `certificateStatus`
|
|
DROP TABLE `certificatesPerName`
|
|
-DROP TABLE `crls`
|
|
+
|
|
+CREATE TABLE `crls` (
|
|
+ `serial` varchar(255) NOT NULL,
|
|
+ `createdAt` datetime NOT NULL,
|
|
+ `crl` varchar(255) NOT NULL,
|
|
+ PRIMARY KEY (`serial`)
|
|
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
+
|
|
DROP TABLE `fqdnSets`
|
|
DROP TABLE `issuedNames`
|
|
DROP TABLE `keyHashToSerial`
|
|
DROP TABLE `newOrdersRL`
|
|
+
|
|
+CREATE TABLE `orderToAuthz` (
|
|
+ `orderID` bigint(20) NOT NULL,
|
|
+ `authzID` varchar(255) NOT NULL,
|
|
+ PRIMARY KEY (`orderID`,`authzID`),
|
|
+ KEY `authzID` (`authzID`)
|
|
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
+
|
|
DROP TABLE `orderToAuthz2`
|
|
DROP TABLE `orders`
|
|
-DROP TABLE `registrations`
|
|
+
|
|
+CREATE TABLE `pendingAuthorizations` (
|
|
+ `id` varchar(255) NOT NULL,
|
|
+ `identifier` varchar(255) NOT NULL,
|
|
+ `registrationID` bigint(20) NOT NULL,
|
|
+ `status` varchar(255) NOT NULL,
|
|
+ `expires` datetime DEFAULT NULL,
|
|
+ `combinations` varchar(255) NOT NULL,
|
|
+ `LockCol` bigint(20) NOT NULL,
|
|
+ PRIMARY KEY (`id`),
|
|
+ KEY `identifier_registrationID_status_expires_idx` (`identifier`,`registrationID`,`status`,`expires`),
|
|
+ KEY `registrationID_status_expires_idx` (`registrationID`,`status`,`expires`),
|
|
+ CONSTRAINT `regId_pending_authz` FOREIGN KEY (`registrationID`) REFERENCES `registrations` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
+
|
|
+-- DROP TABLE `registrations`
|
|
+
|
|
+CREATE TABLE `sctReceipts` (
|
|
+ `id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
+ `sctVersion` tinyint(1) NOT NULL,
|
|
+ `logID` varchar(255) NOT NULL,
|
|
+ `timestamp` bigint(20) NOT NULL,
|
|
+ `extensions` blob DEFAULT NULL,
|
|
+ `signature` blob DEFAULT NULL,
|
|
+ `certificateSerial` varchar(255) NOT NULL,
|
|
+ `LockCol` bigint(20) DEFAULT NULL,
|
|
+ PRIMARY KEY (`id`),
|
|
+ UNIQUE KEY `certificateSerial_logID` (`certificateSerial`,`logID`)
|
|
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
+
|