/*
  Warnings:

  - You are about to drop the column `creation_date` on the `person` table. All the data in the column will be lost.
  - You are about to drop the column `registration_date` on the `user` table. All the data in the column will be lost.
  - A unique constraint covering the columns `[user_id]` on the table `person` will be added. If there are existing duplicate values, this will fail.
  - Added the required column `user_id` to the `person` table without a default value. This is not possible if the table is not empty.

*/
-- DropForeignKey
ALTER TABLE "person" DROP CONSTRAINT "person_id_fkey";

-- DropIndex
DROP INDEX "person_id_key";

-- DropIndex
DROP INDEX "planting_rule_tree_size_key";

-- AlterTable
CREATE SEQUENCE balance_id_seq;
ALTER TABLE "balance" ALTER COLUMN "id" SET DEFAULT nextval('balance_id_seq');
ALTER SEQUENCE balance_id_seq OWNED BY "balance"."id";

-- AlterTable
ALTER TABLE "person" DROP COLUMN "creation_date",
ADD COLUMN     "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN     "user_id" TEXT NOT NULL;

-- AlterTable
ALTER TABLE "user" DROP COLUMN "registration_date",
ADD COLUMN     "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP;

-- CreateIndex
CREATE UNIQUE INDEX "person_user_id_key" ON "person"("user_id");

-- AddForeignKey
ALTER TABLE "person" ADD CONSTRAINT "person_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "user"("id") ON DELETE RESTRICT ON UPDATE CASCADE;
