Commit 50e809da authored by Nawasan Wisitsingkhon's avatar Nawasan Wisitsingkhon

remove migrate

parent 42198965
-- CreateTable
CREATE TABLE `users` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL,
`username` VARCHAR(191) NOT NULL,
`password` VARCHAR(191) NOT NULL,
UNIQUE INDEX `users_username_key`(`username`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
/*
Warnings:
- You are about to drop the `users` table. If the table is not empty, all the data it contains will be lost.
*/
-- DropTable
DROP TABLE `users`;
-- CreateTable
CREATE TABLE `user` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL,
`email` VARCHAR(191) NOT NULL,
`phone` VARCHAR(191) NOT NULL,
`photo` VARCHAR(191) NOT NULL,
`google_token` VARCHAR(191) NOT NULL,
`username` VARCHAR(191) NOT NULL,
`password` VARCHAR(191) NOT NULL,
`rank` BOOLEAN NOT NULL,
`register_date` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
UNIQUE INDEX `user_username_key`(`username`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `product` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL,
`detail` VARCHAR(191) NOT NULL,
`price` INTEGER NOT NULL,
`discount` INTEGER NOT NULL,
`cateId` INTEGER NOT NULL,
`watch_count` INTEGER NOT NULL,
`buy_count` INTEGER NOT NULL,
`image` VARCHAR(191) NOT NULL,
`stock` INTEGER NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `category` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`name` VARCHAR(191) NOT NULL,
UNIQUE INDEX `category_name_key`(`name`),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `wishlist` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`productId` INTEGER NOT NULL,
`userId` INTEGER NOT NULL,
`date` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `cart` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`userId` INTEGER NOT NULL,
`productId` INTEGER NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `order` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`userId` INTEGER NOT NULL,
`total_price` INTEGER NOT NULL,
`product_count` INTEGER NOT NULL,
`date` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3),
`shipping_price` INTEGER NOT NULL,
`pay_status` INTEGER NOT NULL,
`send_status` INTEGER NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- CreateTable
CREATE TABLE `order_detail` (
`id` INTEGER NOT NULL AUTO_INCREMENT,
`orderId` INTEGER NOT NULL,
`userId` INTEGER NOT NULL,
`productId` INTEGER NOT NULL,
`product_price` INTEGER NOT NULL,
`product_discount` INTEGER NOT NULL,
PRIMARY KEY (`id`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- AddForeignKey
ALTER TABLE `product` ADD CONSTRAINT `product_cateId_fkey` FOREIGN KEY (`cateId`) REFERENCES `category`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `wishlist` ADD CONSTRAINT `wishlist_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `product`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `wishlist` ADD CONSTRAINT `wishlist_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `cart` ADD CONSTRAINT `cart_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `cart` ADD CONSTRAINT `cart_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `product`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `order` ADD CONSTRAINT `order_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `order_detail` ADD CONSTRAINT `order_detail_orderId_fkey` FOREIGN KEY (`orderId`) REFERENCES `order`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `order_detail` ADD CONSTRAINT `order_detail_userId_fkey` FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `order_detail` ADD CONSTRAINT `order_detail_productId_fkey` FOREIGN KEY (`productId`) REFERENCES `product`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
/*
Warnings:
- You are about to drop the column `productId` on the `cart` table. All the data in the column will be lost.
- You are about to drop the column `userId` on the `cart` table. All the data in the column will be lost.
- You are about to drop the column `userId` on the `order` table. All the data in the column will be lost.
- You are about to drop the column `orderId` on the `order_detail` table. All the data in the column will be lost.
- You are about to drop the column `productId` on the `order_detail` table. All the data in the column will be lost.
- You are about to drop the column `userId` on the `order_detail` table. All the data in the column will be lost.
- You are about to drop the column `productId` on the `wishlist` table. All the data in the column will be lost.
- You are about to drop the column `userId` on the `wishlist` table. All the data in the column will be lost.
- Added the required column `product_id` to the `cart` table without a default value. This is not possible if the table is not empty.
- Added the required column `user_id` to the `cart` table without a default value. This is not possible if the table is not empty.
- Added the required column `user_id` to the `order` table without a default value. This is not possible if the table is not empty.
- Added the required column `order_id` to the `order_detail` table without a default value. This is not possible if the table is not empty.
- Added the required column `product_id` to the `order_detail` table without a default value. This is not possible if the table is not empty.
- Added the required column `user_id` to the `order_detail` table without a default value. This is not possible if the table is not empty.
- Added the required column `product_id` to the `wishlist` table without a default value. This is not possible if the table is not empty.
- Added the required column `user_id` to the `wishlist` table without a default value. This is not possible if the table is not empty.
*/
-- DropForeignKey
ALTER TABLE `cart` DROP FOREIGN KEY `cart_productId_fkey`;
-- DropForeignKey
ALTER TABLE `cart` DROP FOREIGN KEY `cart_userId_fkey`;
-- DropForeignKey
ALTER TABLE `order` DROP FOREIGN KEY `order_userId_fkey`;
-- DropForeignKey
ALTER TABLE `order_detail` DROP FOREIGN KEY `order_detail_orderId_fkey`;
-- DropForeignKey
ALTER TABLE `order_detail` DROP FOREIGN KEY `order_detail_productId_fkey`;
-- DropForeignKey
ALTER TABLE `order_detail` DROP FOREIGN KEY `order_detail_userId_fkey`;
-- DropForeignKey
ALTER TABLE `wishlist` DROP FOREIGN KEY `wishlist_productId_fkey`;
-- DropForeignKey
ALTER TABLE `wishlist` DROP FOREIGN KEY `wishlist_userId_fkey`;
-- AlterTable
ALTER TABLE `cart` DROP COLUMN `productId`,
DROP COLUMN `userId`,
ADD COLUMN `product_id` INTEGER NOT NULL,
ADD COLUMN `user_id` INTEGER NOT NULL;
-- AlterTable
ALTER TABLE `order` DROP COLUMN `userId`,
ADD COLUMN `user_id` INTEGER NOT NULL;
-- AlterTable
ALTER TABLE `order_detail` DROP COLUMN `orderId`,
DROP COLUMN `productId`,
DROP COLUMN `userId`,
ADD COLUMN `order_id` INTEGER NOT NULL,
ADD COLUMN `product_id` INTEGER NOT NULL,
ADD COLUMN `user_id` INTEGER NOT NULL;
-- AlterTable
ALTER TABLE `wishlist` DROP COLUMN `productId`,
DROP COLUMN `userId`,
ADD COLUMN `product_id` INTEGER NOT NULL,
ADD COLUMN `user_id` INTEGER NOT NULL;
-- AddForeignKey
ALTER TABLE `wishlist` ADD CONSTRAINT `wishlist_product_id_fkey` FOREIGN KEY (`product_id`) REFERENCES `product`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `wishlist` ADD CONSTRAINT `wishlist_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `cart` ADD CONSTRAINT `cart_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `cart` ADD CONSTRAINT `cart_product_id_fkey` FOREIGN KEY (`product_id`) REFERENCES `product`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `order` ADD CONSTRAINT `order_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `order_detail` ADD CONSTRAINT `order_detail_order_id_fkey` FOREIGN KEY (`order_id`) REFERENCES `order`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `order_detail` ADD CONSTRAINT `order_detail_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `user`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AddForeignKey
ALTER TABLE `order_detail` ADD CONSTRAINT `order_detail_product_id_fkey` FOREIGN KEY (`product_id`) REFERENCES `product`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE;
-- AlterTable
ALTER TABLE `product` MODIFY `image` LONGTEXT NOT NULL;
-- AlterTable
ALTER TABLE `product` MODIFY `detail` LONGTEXT NOT NULL;
-- AlterTable
ALTER TABLE `user` MODIFY `photo` LONGTEXT NOT NULL;
/*
Warnings:
- Added the required column `count` to the `order_detail` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE `order` ADD COLUMN `address` LONGTEXT NOT NULL DEFAULT '';
-- AlterTable
ALTER TABLE `order_detail` ADD COLUMN `count` INTEGER NOT NULL;
-- AlterTable
ALTER TABLE `user` ADD COLUMN `address` LONGTEXT NOT NULL DEFAULT '';
# Please do not edit this file manually
# It should be added in your version-control system (i.e. Git)
provider = "mysql"
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment