35 lines
1.2 KiB
SQL
35 lines
1.2 KiB
SQL
-- +goose Up
|
|
-- SQL in section 'Up' is executed when this migration is applied
|
|
|
|
CREATE TABLE `serials` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`registrationID` bigint(20) NOT NULL,
|
|
`serial` varchar(255) NOT NULL,
|
|
`created` datetime NOT NULL,
|
|
`expires` datetime NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `serial` (`serial`),
|
|
KEY `regId_serials_idx` (`registrationID`),
|
|
CONSTRAINT `regId_serials` FOREIGN KEY (`registrationID`) REFERENCES `registrations` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
CREATE TABLE `precertificates` (
|
|
`id` bigint(20) NOT NULL AUTO_INCREMENT,
|
|
`registrationID` bigint(20) NOT NULL,
|
|
`serial` varchar(255) NOT NULL,
|
|
`der` mediumblob NOT NULL,
|
|
`issued` datetime NOT NULL,
|
|
`expires` datetime NOT NULL,
|
|
PRIMARY KEY (`id`),
|
|
UNIQUE KEY `serial` (`serial`),
|
|
KEY `regId_precertificates_idx` (`registrationID`),
|
|
KEY `issued_precertificates_idx` (`issued`),
|
|
CONSTRAINT `regId_precertificates` FOREIGN KEY (`registrationID`) REFERENCES `registrations` (`id`) ON DELETE NO ACTION ON UPDATE NO ACTION
|
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
|
|
|
-- +goose Down
|
|
-- SQL section 'Down' is executed when this migration is rolled back
|
|
|
|
DROP TABLE serials;
|
|
DROP TABLE precertificates;
|