-- CreateTable CREATE TABLE "Country" ( "id" TEXT NOT NULL, "name" TEXT NOT NULL, "code" TEXT NOT NULL, CONSTRAINT "Country_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "State" ( "id" TEXT NOT NULL, "name" TEXT NOT NULL, "countryId" TEXT NOT NULL, CONSTRAINT "State_pkey" PRIMARY KEY ("id") ); -- CreateTable CREATE TABLE "City" ( "id" TEXT NOT NULL, "name" TEXT NOT NULL, "stateId" TEXT NOT NULL, CONSTRAINT "City_pkey" PRIMARY KEY ("id") ); -- CreateIndex CREATE UNIQUE INDEX "Country_name_key" ON "Country"("name"); -- CreateIndex CREATE UNIQUE INDEX "Country_code_key" ON "Country"("code"); -- CreateIndex CREATE UNIQUE INDEX "State_name_countryId_key" ON "State"("name", "countryId"); -- CreateIndex CREATE UNIQUE INDEX "City_name_stateId_key" ON "City"("name", "stateId"); -- AddForeignKey ALTER TABLE "State" ADD CONSTRAINT "State_countryId_fkey" FOREIGN KEY ("countryId") REFERENCES "Country"("id") ON DELETE RESTRICT ON UPDATE CASCADE; -- AddForeignKey ALTER TABLE "City" ADD CONSTRAINT "City_stateId_fkey" FOREIGN KEY ("stateId") REFERENCES "State"("id") ON DELETE RESTRICT ON UPDATE CASCADE;