-- CreateTable
CREATE TABLE `x_category` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(191) NOT NULL DEFAULT '',
    `sort` INTEGER NOT NULL DEFAULT 0,
    `status` INTEGER NOT NULL DEFAULT 1,
    `thumb` VARCHAR(191) NOT NULL DEFAULT '',
    `desc` VARCHAR(191) NOT NULL DEFAULT '',
    `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;

-- CreateTable
CREATE TABLE `x_goods` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(191) NOT NULL DEFAULT '',
    `desc` VARCHAR(191) NULL DEFAULT '',
    `thumb` VARCHAR(191) NULL DEFAULT '',
    `images` VARCHAR(191) NULL DEFAULT '',
    `common_name` VARCHAR(191) NULL DEFAULT '',
    `common_weight` VARCHAR(191) NULL DEFAULT '',
    `common_type` VARCHAR(191) NULL DEFAULT '',
    `common_no` VARCHAR(191) NULL DEFAULT '',
    `common_desc` VARCHAR(191) NULL DEFAULT '',
    `common_ident` VARCHAR(191) NULL DEFAULT '',
    `common_spec` VARCHAR(191) NULL DEFAULT '',
    `common_content` TEXT NULL,
    `use_data` TEXT NULL,
    `explain` TEXT NULL,
    `status` INTEGER NOT NULL DEFAULT 1,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,
    `categoryId` INTEGER NOT NULL,

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

-- CreateTable
CREATE TABLE `x_role` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `name` VARCHAR(191) NOT NULL,
    `desc` VARCHAR(191) NOT NULL,
    `status` INTEGER NOT NULL DEFAULT 1,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `x_role_name_key`(`name`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
CREATE TABLE `x_user` (
    `id` INTEGER NOT NULL AUTO_INCREMENT,
    `username` VARCHAR(191) NOT NULL,
    `password` VARCHAR(191) NULL,
    `nickname` VARCHAR(191) NULL,
    `avatar` VARCHAR(191) NULL,
    `status` INTEGER NOT NULL DEFAULT 1,
    `roleId` INTEGER NOT NULL,
    `isDelete` INTEGER NOT NULL DEFAULT 0,
    `createdAt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
    `updatedAt` DATETIME(3) NOT NULL,

    UNIQUE INDEX `x_user_username_key`(`username`),
    PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- AddForeignKey
ALTER TABLE `x_goods` ADD CONSTRAINT `x_goods_categoryId_fkey` FOREIGN KEY (`categoryId`) REFERENCES `x_category`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `x_user` ADD CONSTRAINT `x_user_roleId_fkey` FOREIGN KEY (`roleId`) REFERENCES `x_role`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
