-- Account audit: which admin created / last updated each User row
ALTER TABLE `User` ADD COLUMN `createdById` VARCHAR(191) NULL,
    ADD COLUMN `updatedById` VARCHAR(191) NULL;

ALTER TABLE `User` ADD CONSTRAINT `User_createdById_fkey` FOREIGN KEY (`createdById`) REFERENCES `User`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

ALTER TABLE `User` ADD CONSTRAINT `User_updatedById_fkey` FOREIGN KEY (`updatedById`) REFERENCES `User`(`id`) ON DELETE SET NULL ON UPDATE CASCADE;

CREATE INDEX `User_createdAt_idx` ON `User`(`createdAt`);
CREATE INDEX `User_updatedAt_idx` ON `User`(`updatedAt`);
CREATE INDEX `User_createdById_idx` ON `User`(`createdById`);
CREATE INDEX `User_updatedById_idx` ON `User`(`updatedById`);
