-- CreateTable
CREATE TABLE "tbl_user_address" (
    "id" BIGSERIAL NOT NULL,
    "user_id" BIGINT,
    "first_name" VARCHAR(216),
    "last_name" VARCHAR(216),
    "address" VARCHAR(256),
    "city" VARCHAR(128),
    "country" VARCHAR(128),
    "country_id" BIGINT,
    "zip_code" VARCHAR(64),
    "country_code" VARCHAR(8),
    "mobile_number" VARCHAR(18),
    "vat_number" VARCHAR(128),
    "is_dont_have_vat_number" BOOLEAN DEFAULT false,
    "is_default" BOOLEAN DEFAULT false,
    "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_user_address_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE INDEX "tbl_user_address_user_id_idx" ON "tbl_user_address"("user_id");

-- CreateIndex
CREATE INDEX "tbl_user_address_first_name_idx" ON "tbl_user_address"("first_name");

-- CreateIndex
CREATE INDEX "tbl_user_address_last_name_idx" ON "tbl_user_address"("last_name");

-- CreateIndex
CREATE INDEX "tbl_user_address_address_idx" ON "tbl_user_address"("address");

-- CreateIndex
CREATE INDEX "tbl_user_address_city_idx" ON "tbl_user_address"("city");

-- CreateIndex
CREATE INDEX "tbl_user_address_country_idx" ON "tbl_user_address"("country");

-- CreateIndex
CREATE INDEX "tbl_user_address_zip_code_idx" ON "tbl_user_address"("zip_code");

-- CreateIndex
CREATE INDEX "tbl_user_address_country_code_idx" ON "tbl_user_address"("country_code");

-- CreateIndex
CREATE INDEX "tbl_user_address_mobile_number_idx" ON "tbl_user_address"("mobile_number");

-- CreateIndex
CREATE INDEX "tbl_user_address_vat_number_idx" ON "tbl_user_address"("vat_number");

-- CreateIndex
CREATE INDEX "tbl_user_address_is_dont_have_vat_number_idx" ON "tbl_user_address"("is_dont_have_vat_number");

-- CreateIndex
CREATE INDEX "tbl_user_address_is_default_idx" ON "tbl_user_address"("is_default");

-- CreateIndex
CREATE INDEX "country_short_name_idx" ON "country"("short_name");

-- CreateIndex
CREATE INDEX "country_name_idx" ON "country"("name");

-- CreateIndex
CREATE INDEX "country_phone_code_idx" ON "country"("phone_code");

-- AddForeignKey
ALTER TABLE "tbl_user_address" ADD CONSTRAINT "tbl_user_address_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "tbl_user"("id") ON DELETE SET NULL ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE "tbl_user_address" ADD CONSTRAINT "tbl_user_address_country_id_fkey" FOREIGN KEY ("country_id") REFERENCES "country"("id") ON DELETE SET NULL ON UPDATE CASCADE;
