-- CreateTable
CREATE TABLE `Kategori` (
    `kategori_id` INTEGER NOT NULL AUTO_INCREMENT,
    `kode_kategori` VARCHAR(191) NOT NULL,
    `nama_kategori` VARCHAR(191) NOT NULL,
    `deskripsi` VARCHAR(191) NULL,

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

-- CreateTable
CREATE TABLE `Lokasi` (
    `lokasi_id` INTEGER NOT NULL AUTO_INCREMENT,
    `kode_lokasi` VARCHAR(191) NOT NULL,
    `nama_lokasi` VARCHAR(191) NOT NULL,
    `deskripsi` VARCHAR(191) NULL,

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

-- CreateTable
CREATE TABLE `Barang` (
    `barang_id` INTEGER NOT NULL AUTO_INCREMENT,
    `kode_barang` VARCHAR(191) NOT NULL,
    `nama_barang` VARCHAR(191) NOT NULL,
    `kategori_id` INTEGER NOT NULL,
    `lokasi_id` INTEGER NOT NULL,
    `status_barang` VARCHAR(191) NOT NULL,

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

-- CreateTable
CREATE TABLE `BAST` (
    `bast_id` INTEGER NOT NULL AUTO_INCREMENT,
    `barang_id` INTEGER NOT NULL,
    `user_serah_id` INTEGER NOT NULL,
    `user_terima_id` INTEGER NOT NULL,
    `status_serah` VARCHAR(191) NOT NULL,
    `status_terima` VARCHAR(191) NOT NULL,

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

-- AddForeignKey
ALTER TABLE `Barang` ADD CONSTRAINT `Barang_kategori_id_fkey` FOREIGN KEY (`kategori_id`) REFERENCES `Kategori`(`kategori_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Barang` ADD CONSTRAINT `Barang_lokasi_id_fkey` FOREIGN KEY (`lokasi_id`) REFERENCES `Lokasi`(`lokasi_id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `BAST` ADD CONSTRAINT `BAST_barang_id_fkey` FOREIGN KEY (`barang_id`) REFERENCES `Barang`(`barang_id`) ON DELETE RESTRICT ON UPDATE CASCADE;
