Skip to content

Commit

Permalink
feat: change to postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
Vann-Dev committed May 11, 2024
1 parent 8b6612b commit 9fb17f8
Show file tree
Hide file tree
Showing 15 changed files with 62 additions and 195 deletions.
57 changes: 0 additions & 57 deletions migrations/20240430160049_feat_add_model/migration.sql

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions migrations/20240502041357_feat_add_admin_model/migration.sql

This file was deleted.

15 changes: 0 additions & 15 deletions migrations/20240502085152_refactor_remove_admin/migration.sql

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

23 changes: 0 additions & 23 deletions migrations/20240506184725_fix_delete_cascade/migration.sql

This file was deleted.

58 changes: 58 additions & 0 deletions migrations/20240511020013_feat_move_to_postgress/migration.sql
Original file line number Diff line number Diff line change
@@ -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;
2 changes: 1 addition & 1 deletion migrations/migration_lock.toml
Original file line number Diff line number Diff line change
@@ -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"
provider = "postgresql"
5 changes: 3 additions & 2 deletions schema.prisma
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
provider = "postgresql"
url = env("DATABASE_URL")
directUrl = env("DIRECT_URL")
}

generator db {
Expand Down

0 comments on commit 9fb17f8

Please sign in to comment.