integratedhub/drizzle/0001_spicy_sunset_bain.sql
2026-01-28 14:49:35 -06:00

64 lines
4.3 KiB
SQL

CREATE TABLE "reminders" (
"id" text PRIMARY KEY NOT NULL,
"user_id" text NOT NULL,
"lease_id" text,
"reminder_type" text NOT NULL,
"title" text NOT NULL,
"description" text,
"due_date" bigint NOT NULL,
"is_completed" boolean DEFAULT false,
"created_on" bigint,
"updated_on" bigint
);
--> statement-breakpoint
CREATE TABLE "tenant_invites" (
"id" text PRIMARY KEY NOT NULL,
"landlord_id" text,
"property_id" text,
"lease_id" text,
"available_on" bigint,
"invited_emails" text,
"created_on" bigint,
"updated_on" bigint
);
--> statement-breakpoint
CREATE TABLE "web_tokens" (
"token_id" varchar(64) PRIMARY KEY NOT NULL,
"state_id" varchar(36) NOT NULL,
"user_id" text NOT NULL,
"token_type" text NOT NULL,
"token_value" text NOT NULL,
"expires_on" bigint NOT NULL,
"created_on" bigint NOT NULL,
"updated_on" bigint NOT NULL,
"last_used_on" bigint,
"is_active" boolean DEFAULT true,
"metadata" json
);
--> statement-breakpoint
ALTER TABLE "brain_question_progress" ADD COLUMN "current_mode" text DEFAULT 'photo-see-bisaya' NOT NULL;--> statement-breakpoint
ALTER TABLE "brain_question_progress" ADD COLUMN "mode_index" integer DEFAULT 0;--> statement-breakpoint
ALTER TABLE "brain_question_progress" ADD COLUMN "consecutive_first_try" integer DEFAULT 0;--> statement-breakpoint
ALTER TABLE "brain_question_progress" ADD COLUMN "is_review_only" boolean DEFAULT false;--> statement-breakpoint
ALTER TABLE "leases" ADD COLUMN "default_payment_method_id" text;--> statement-breakpoint
ALTER TABLE "messages" ADD COLUMN "parent_message_id" text;--> statement-breakpoint
ALTER TABLE "messages" ADD COLUMN "attachments_json" json;--> statement-breakpoint
ALTER TABLE "properties" ADD COLUMN "default_payment_method_id" text;--> statement-breakpoint
ALTER TABLE "quiz_configs" ADD COLUMN "tab_name" text;--> statement-breakpoint
ALTER TABLE "quiz_configs" ADD COLUMN "tab_index" integer DEFAULT 0;--> statement-breakpoint
ALTER TABLE "quiz_configs" ADD COLUMN "list_index" integer DEFAULT 0;--> statement-breakpoint
ALTER TABLE "quiz_questions" ADD COLUMN "question_index" integer DEFAULT 0;--> statement-breakpoint
ALTER TABLE "tenant_applications" ADD COLUMN "document_urls_json" json;--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "onboarded_landlord" boolean DEFAULT false;--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "onboarded_tenant" boolean DEFAULT false;--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "notification_preferences_json" json;--> statement-breakpoint
ALTER TABLE "users" ADD COLUMN "payment_preferences_json" json;--> statement-breakpoint
ALTER TABLE "reminders" ADD CONSTRAINT "reminders_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "reminders" ADD CONSTRAINT "reminders_lease_id_leases_id_fk" FOREIGN KEY ("lease_id") REFERENCES "public"."leases"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tenant_invites" ADD CONSTRAINT "tenant_invites_landlord_id_users_id_fk" FOREIGN KEY ("landlord_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tenant_invites" ADD CONSTRAINT "tenant_invites_property_id_properties_id_fk" FOREIGN KEY ("property_id") REFERENCES "public"."properties"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "tenant_invites" ADD CONSTRAINT "tenant_invites_lease_id_leases_id_fk" FOREIGN KEY ("lease_id") REFERENCES "public"."leases"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "web_tokens" ADD CONSTRAINT "web_tokens_user_id_users_id_fk" FOREIGN KEY ("user_id") REFERENCES "public"."users"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "leases" ADD CONSTRAINT "leases_default_payment_method_id_payment_methods_id_fk" FOREIGN KEY ("default_payment_method_id") REFERENCES "public"."payment_methods"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "properties" ADD CONSTRAINT "properties_default_payment_method_id_payment_methods_id_fk" FOREIGN KEY ("default_payment_method_id") REFERENCES "public"."payment_methods"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint
ALTER TABLE "brain_question_progress" DROP COLUMN "mode";