/*
  Warnings:

  - You are about to drop the column `permission` on the `tbl_user` table. All the data in the column will be lost.
  - You are about to drop the column `role_id` on the `tbl_user` table. All the data in the column will be lost.
  - You are about to drop the `tbl_role` table. If the table is not empty, all the data it contains will be lost.

*/
-- DropForeignKey
ALTER TABLE "tbl_user" DROP CONSTRAINT "tbl_user_role_id_fkey";

-- AlterTable
ALTER TABLE "tbl_user" DROP COLUMN "permission",
DROP COLUMN "role_id",
ADD COLUMN     "permission_id" BIGINT,
ADD COLUMN     "role" VARCHAR(256);

-- DropTable
DROP TABLE "tbl_role";

-- CreateTable
CREATE TABLE "tbl_permission" (
    "id" BIGSERIAL NOT NULL,
    "role_name" VARCHAR(256),
    "is_active" BOOLEAN DEFAULT true,
    "is_delete" BOOLEAN DEFAULT false,
    "deleted_at" TIMESTAMP(3),
    "inserted_at" TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP,
    "updated_at" TIMESTAMP(3),

    CONSTRAINT "tbl_permission_pkey" PRIMARY KEY ("id")
);

-- AddForeignKey
ALTER TABLE "tbl_user" ADD CONSTRAINT "tbl_user_permission_id_fkey" FOREIGN KEY ("permission_id") REFERENCES "tbl_permission"("id") ON DELETE SET NULL ON UPDATE CASCADE;
