diff --git a/migrations/20240430160049_feat_add_model/migration.sql b/migrations/20240430160049_feat_add_model/migration.sql deleted file mode 100644 index e0d67d3..0000000 --- a/migrations/20240430160049_feat_add_model/migration.sql +++ /dev/null @@ -1,57 +0,0 @@ --- CreateTable -CREATE TABLE `Account` ( - `id` VARCHAR(191) NOT NULL, - `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - `email` VARCHAR(191) NOT NULL, - `password` VARCHAR(191) NOT NULL, - - UNIQUE INDEX `Account_email_key`(`email`), - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - --- CreateTable -CREATE TABLE `Date` ( - `id` VARCHAR(191) NOT NULL, - `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - `date` DATETIME(3) NOT NULL, - `account_id` VARCHAR(191) NOT NULL, - - UNIQUE INDEX `Date_date_key`(`date`), - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - --- CreateTable -CREATE TABLE `Attendance` ( - `id` VARCHAR(191) NOT NULL, - `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - `status` ENUM('AVAILABLE', 'UNAVAILABLE') NOT NULL, - `user_id` VARCHAR(191) NOT NULL, - `date_id` VARCHAR(191) NOT NULL, - - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - --- CreateTable -CREATE TABLE `User` ( - `id` VARCHAR(191) NOT NULL, - `photo` VARCHAR(191) NOT NULL, - `name` VARCHAR(191) NOT NULL, - `nim` VARCHAR(191) NOT NULL, - `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - `account_id` VARCHAR(191) NOT NULL, - - UNIQUE INDEX `User_nim_key`(`nim`), - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - --- AddForeignKey -ALTER TABLE `Date` ADD CONSTRAINT `Date_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `Account`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE `Attendance` ADD CONSTRAINT `Attendance_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `User`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE `Attendance` ADD CONSTRAINT `Attendance_date_id_fkey` FOREIGN KEY (`date_id`) REFERENCES `Date`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE `User` ADD CONSTRAINT `User_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `Account`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/migrations/20240430160330_refactor_change_photo_to_nullable/migration.sql b/migrations/20240430160330_refactor_change_photo_to_nullable/migration.sql deleted file mode 100644 index 65249e8..0000000 --- a/migrations/20240430160330_refactor_change_photo_to_nullable/migration.sql +++ /dev/null @@ -1,2 +0,0 @@ --- AlterTable -ALTER TABLE `User` MODIFY `photo` VARCHAR(191) NULL; diff --git a/migrations/20240502041357_feat_add_admin_model/migration.sql b/migrations/20240502041357_feat_add_admin_model/migration.sql deleted file mode 100644 index 166f72d..0000000 --- a/migrations/20240502041357_feat_add_admin_model/migration.sql +++ /dev/null @@ -1,22 +0,0 @@ -/* - Warnings: - - - Added the required column `admin_id` to the `Account` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterTable -ALTER TABLE `Account` ADD COLUMN `admin_id` VARCHAR(191) NOT NULL; - --- CreateTable -CREATE TABLE `Admin` ( - `id` VARCHAR(191) NOT NULL, - `created_at` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3), - `email` VARCHAR(191) NOT NULL, - `password` VARCHAR(191) NOT NULL, - - UNIQUE INDEX `Admin_email_key`(`email`), - PRIMARY KEY (`id`) -) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; - --- AddForeignKey -ALTER TABLE `Account` ADD CONSTRAINT `Account_admin_id_fkey` FOREIGN KEY (`admin_id`) REFERENCES `Admin`(`id`) ON DELETE RESTRICT ON UPDATE CASCADE; diff --git a/migrations/20240502085152_refactor_remove_admin/migration.sql b/migrations/20240502085152_refactor_remove_admin/migration.sql deleted file mode 100644 index e4173a5..0000000 --- a/migrations/20240502085152_refactor_remove_admin/migration.sql +++ /dev/null @@ -1,15 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `admin_id` on the `Account` table. All the data in the column will be lost. - - You are about to drop the `Admin` table. If the table is not empty, all the data it contains will be lost. - -*/ --- DropForeignKey -ALTER TABLE `Account` DROP FOREIGN KEY `Account_admin_id_fkey`; - --- AlterTable -ALTER TABLE `Account` DROP COLUMN `admin_id`; - --- DropTable -DROP TABLE `Admin`; diff --git a/migrations/20240503213015_feat_add_ip_address_to_attendance/migration.sql b/migrations/20240503213015_feat_add_ip_address_to_attendance/migration.sql deleted file mode 100644 index d56c6a0..0000000 --- a/migrations/20240503213015_feat_add_ip_address_to_attendance/migration.sql +++ /dev/null @@ -1,12 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[ip_address]` on the table `Attendance` will be added. If there are existing duplicate values, this will fail. - - Added the required column `ip_address` to the `Attendance` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterTable -ALTER TABLE `Attendance` ADD COLUMN `ip_address` VARCHAR(191) NOT NULL; - --- CreateIndex -CREATE UNIQUE INDEX `Attendance_ip_address_key` ON `Attendance`(`ip_address`); diff --git a/migrations/20240503215629_feat_add_visitor_identifier/migration.sql b/migrations/20240503215629_feat_add_visitor_identifier/migration.sql deleted file mode 100644 index 9055aab..0000000 --- a/migrations/20240503215629_feat_add_visitor_identifier/migration.sql +++ /dev/null @@ -1,12 +0,0 @@ -/* - Warnings: - - - A unique constraint covering the columns `[visitor_identifier]` on the table `Attendance` will be added. If there are existing duplicate values, this will fail. - - Added the required column `visitor_identifier` to the `Attendance` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterTable -ALTER TABLE `Attendance` ADD COLUMN `visitor_identifier` VARCHAR(191) NOT NULL; - --- CreateIndex -CREATE UNIQUE INDEX `Attendance_visitor_identifier_key` ON `Attendance`(`visitor_identifier`); diff --git a/migrations/20240503223334_refactor_change_user_and_attendance_to_non_unique/migration.sql b/migrations/20240503223334_refactor_change_user_and_attendance_to_non_unique/migration.sql deleted file mode 100644 index 9ef0bff..0000000 --- a/migrations/20240503223334_refactor_change_user_and_attendance_to_non_unique/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ --- DropIndex -DROP INDEX `Attendance_ip_address_key` ON `Attendance`; - --- DropIndex -DROP INDEX `Attendance_visitor_identifier_key` ON `Attendance`; - --- DropIndex -DROP INDEX `User_nim_key` ON `User`; diff --git a/migrations/20240504162426_refactor_remove_created_at_in_date/migration.sql b/migrations/20240504162426_refactor_remove_created_at_in_date/migration.sql deleted file mode 100644 index 886de4e..0000000 --- a/migrations/20240504162426_refactor_remove_created_at_in_date/migration.sql +++ /dev/null @@ -1,11 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `created_at` on the `Date` table. All the data in the column will be lost. - -*/ --- DropIndex -DROP INDEX `Date_date_key` ON `Date`; - --- AlterTable -ALTER TABLE `Date` DROP COLUMN `created_at`; diff --git a/migrations/20240504165032_refactor_change_date_into_day_month_year/migration.sql b/migrations/20240504165032_refactor_change_date_into_day_month_year/migration.sql deleted file mode 100644 index 9f53fc1..0000000 --- a/migrations/20240504165032_refactor_change_date_into_day_month_year/migration.sql +++ /dev/null @@ -1,14 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `date` on the `Date` table. All the data in the column will be lost. - - Added the required column `day` to the `Date` table without a default value. This is not possible if the table is not empty. - - Added the required column `month` to the `Date` table without a default value. This is not possible if the table is not empty. - - Added the required column `year` to the `Date` table without a default value. This is not possible if the table is not empty. - -*/ --- AlterTable -ALTER TABLE `Date` DROP COLUMN `date`, - ADD COLUMN `day` INTEGER NOT NULL, - ADD COLUMN `month` INTEGER NOT NULL, - ADD COLUMN `year` INTEGER NOT NULL; diff --git a/migrations/20240504175339_refactor_remove_status_in_attendance/migration.sql b/migrations/20240504175339_refactor_remove_status_in_attendance/migration.sql deleted file mode 100644 index 3567283..0000000 --- a/migrations/20240504175339_refactor_remove_status_in_attendance/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `status` on the `Attendance` table. All the data in the column will be lost. - -*/ --- AlterTable -ALTER TABLE `Attendance` DROP COLUMN `status`; diff --git a/migrations/20240505135124_del_remove_photo_from_user/migration.sql b/migrations/20240505135124_del_remove_photo_from_user/migration.sql deleted file mode 100644 index 2a7e791..0000000 --- a/migrations/20240505135124_del_remove_photo_from_user/migration.sql +++ /dev/null @@ -1,8 +0,0 @@ -/* - Warnings: - - - You are about to drop the column `photo` on the `User` table. All the data in the column will be lost. - -*/ --- AlterTable -ALTER TABLE `User` DROP COLUMN `photo`; diff --git a/migrations/20240506184725_fix_delete_cascade/migration.sql b/migrations/20240506184725_fix_delete_cascade/migration.sql deleted file mode 100644 index 5528e6c..0000000 --- a/migrations/20240506184725_fix_delete_cascade/migration.sql +++ /dev/null @@ -1,23 +0,0 @@ --- DropForeignKey -ALTER TABLE `Attendance` DROP FOREIGN KEY `Attendance_date_id_fkey`; - --- DropForeignKey -ALTER TABLE `Attendance` DROP FOREIGN KEY `Attendance_user_id_fkey`; - --- DropForeignKey -ALTER TABLE `Date` DROP FOREIGN KEY `Date_account_id_fkey`; - --- DropForeignKey -ALTER TABLE `User` DROP FOREIGN KEY `User_account_id_fkey`; - --- AddForeignKey -ALTER TABLE `Date` ADD CONSTRAINT `Date_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `Account`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE `Attendance` ADD CONSTRAINT `Attendance_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `User`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE `Attendance` ADD CONSTRAINT `Attendance_date_id_fkey` FOREIGN KEY (`date_id`) REFERENCES `Date`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; - --- AddForeignKey -ALTER TABLE `User` ADD CONSTRAINT `User_account_id_fkey` FOREIGN KEY (`account_id`) REFERENCES `Account`(`id`) ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/migrations/20240511020013_feat_move_to_postgress/migration.sql b/migrations/20240511020013_feat_move_to_postgress/migration.sql new file mode 100644 index 0000000..e19166a --- /dev/null +++ b/migrations/20240511020013_feat_move_to_postgress/migration.sql @@ -0,0 +1,58 @@ +-- CreateTable +CREATE TABLE "Account" ( + "id" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "email" TEXT NOT NULL, + "password" TEXT NOT NULL, + + CONSTRAINT "Account_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Date" ( + "id" TEXT NOT NULL, + "day" INTEGER NOT NULL, + "month" INTEGER NOT NULL, + "year" INTEGER NOT NULL, + "account_id" TEXT NOT NULL, + + CONSTRAINT "Date_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "Attendance" ( + "id" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "user_id" TEXT NOT NULL, + "date_id" TEXT NOT NULL, + "visitor_identifier" TEXT NOT NULL, + "ip_address" TEXT NOT NULL, + + CONSTRAINT "Attendance_pkey" PRIMARY KEY ("id") +); + +-- CreateTable +CREATE TABLE "User" ( + "id" TEXT NOT NULL, + "name" TEXT NOT NULL, + "nim" TEXT NOT NULL, + "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "account_id" TEXT NOT NULL, + + CONSTRAINT "User_pkey" PRIMARY KEY ("id") +); + +-- CreateIndex +CREATE UNIQUE INDEX "Account_email_key" ON "Account"("email"); + +-- AddForeignKey +ALTER TABLE "Date" ADD CONSTRAINT "Date_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Attendance" ADD CONSTRAINT "Attendance_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "User"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "Attendance" ADD CONSTRAINT "Attendance_date_id_fkey" FOREIGN KEY ("date_id") REFERENCES "Date"("id") ON DELETE CASCADE ON UPDATE CASCADE; + +-- AddForeignKey +ALTER TABLE "User" ADD CONSTRAINT "User_account_id_fkey" FOREIGN KEY ("account_id") REFERENCES "Account"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/migrations/migration_lock.toml b/migrations/migration_lock.toml index e5a788a..fbffa92 100644 --- a/migrations/migration_lock.toml +++ b/migrations/migration_lock.toml @@ -1,3 +1,3 @@ # 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 +provider = "postgresql" \ No newline at end of file diff --git a/schema.prisma b/schema.prisma index fef95eb..87b3540 100644 --- a/schema.prisma +++ b/schema.prisma @@ -1,6 +1,7 @@ datasource db { - provider = "postgresql" - url = env("DATABASE_URL") + provider = "postgresql" + url = env("DATABASE_URL") + directUrl = env("DIRECT_URL") } generator db {