All checks were successful
Build on push / prepare (push) Successful in 10s
Build on push / core (push) Successful in 19s
Build on push / query (push) Successful in 18s
Build on push / dependency (push) Successful in 17s
Build on push / database (push) Successful in 15s
Build on push / translation (push) Successful in 18s
Build on push / mail (push) Successful in 19s
Build on push / application (push) Successful in 21s
Build on push / auth (push) Successful in 14s
Build on push / api (push) Successful in 14s
47 lines
1.5 KiB
SQL
47 lines
1.5 KiB
SQL
CREATE TABLE IF NOT EXISTS administration_api_keys
|
|
(
|
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
|
identifier VARCHAR(255) NOT NULL,
|
|
keyString VARCHAR(255) NOT NULL,
|
|
deleted BOOL NOT NULL DEFAULT FALSE,
|
|
editorId INT NULL,
|
|
created TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
|
updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
|
|
|
CONSTRAINT UC_Identifier_Key UNIQUE (identifier, keyString),
|
|
CONSTRAINT UC_Key UNIQUE (keyString),
|
|
CONSTRAINT FK_ApiKeys_Editor FOREIGN KEY (editorId) REFERENCES administration_auth_users (id)
|
|
);
|
|
|
|
CREATE TABLE IF NOT EXISTS administration_api_keys_history
|
|
(
|
|
id INT NOT NULL,
|
|
identifier VARCHAR(255) NOT NULL,
|
|
keyString VARCHAR(255) NOT NULL,
|
|
deleted BOOL NOT NULL,
|
|
editorId INT NULL,
|
|
created TIMESTAMP NOT NULL,
|
|
updated TIMESTAMP NOT NULL
|
|
);
|
|
|
|
|
|
CREATE TRIGGER TR_ApiKeysUpdate
|
|
AFTER UPDATE
|
|
ON administration_api_keys
|
|
FOR EACH ROW
|
|
BEGIN
|
|
INSERT INTO administration_api_keys_history
|
|
(id, identifier, keyString, deleted, editorId, created, updated)
|
|
VALUES (OLD.id, OLD.identifier, OLD.keyString, OLD.deleted, OLD.editorId, OLD.created, NOW());
|
|
END;
|
|
|
|
CREATE TRIGGER TR_ApiKeysDelete
|
|
AFTER DELETE
|
|
ON administration_api_keys
|
|
FOR EACH ROW
|
|
BEGIN
|
|
INSERT INTO administration_api_keys_history
|
|
(id, identifier, keyString, deleted, editorId, created, updated)
|
|
VALUES (OLD.id, OLD.identifier, OLD.keyString, 1, OLD.editorId, OLD.created, NOW());
|
|
END;
|