Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- CreateEnum
- CREATE TYPE "Hobby" AS ENUM ('ENTREPRENEUR', 'SPORT', 'MUSIC', 'MOVIE', 'CODING', 'TRAVELING', 'WORKING', 'LEARNING');
- -- CreateTable
- CREATE TABLE "tasks" (
- "id" SERIAL NOT NULL,
- "firstname" VARCHAR(100) NOT NULL,
- "imageId" VARCHAR(36) NOT NULL,
- "hobbies" "Hobby" NOT NULL DEFAULT E'LEARNING',
- "favoriteNumbers" INTEGER[],
- CONSTRAINT "tasks_pkey" PRIMARY KEY ("id")
- );
- -- But this migration fails because I have records that their hobbies is full
- -- AlterTable
- ALTER TABLE "tasks" ALTER COLUMN "hobbies" DROP DEFAULT,
- ALTER COLUMN "hobbies" SET DATA TYPE "Hobby"[];
- -- You have to use USING:
- ALTER TABLE "tasks" ALTER COLUMN "hobbies" DROP DEFAULT,
- ALTER COLUMN "hobbies" SET DATA TYPE "Hobby"[] USING ARRAY["hobbies"];
Add Comment
Please, Sign In to add comment