/*
  Warnings:

  - Added the required column `characterTypeId` to the `Character` table without a default value. This is not possible if the table is not empty.

*/
-- AlterTable
ALTER TABLE `Character` ADD COLUMN `characterTypeId` INTEGER NOT NULL;

-- AlterTable
ALTER TABLE `Sprite` ADD COLUMN `isAnimated` BOOLEAN NOT NULL DEFAULT false;

-- CreateTable
CREATE TABLE `CharacterSprite` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `characterTypeId` INTEGER NOT NULL,
    `spriteId` VARCHAR(191) NOT NULL,
    `action` ENUM('IDLE_LEFT', 'IDLE_DOWN', 'SIT_LEFT', 'SIT_DOWN', 'WALK_LEFT', 'WALK_DOWN', 'ATTACK_LEFT', 'ATTACK_DOWN') NOT NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `CharacterType` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(191) NOT NULL,
    `gender` ENUM('MALE', 'FEMALE') NOT NULL,
    `race` ENUM('HUMAN', 'ELF', 'DWARF', 'ORC', 'GOBLIN') NOT NULL,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `CharacterSprite` ADD CONSTRAINT `CharacterSprite_characterTypeId_fkey` FOREIGN KEY (`characterTypeId`) REFERENCES `CharacterType`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `CharacterSprite` ADD CONSTRAINT `CharacterSprite_spriteId_fkey` FOREIGN KEY (`spriteId`) REFERENCES `Sprite`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Character` ADD CONSTRAINT `Character_characterTypeId_fkey` FOREIGN KEY (`characterTypeId`) REFERENCES `CharacterType`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;
