24 lines
681 B
SQL
24 lines
681 B
SQL
-- Migration: Create tenant invites table
|
|
|
|
CREATE TABLE IF NOT EXISTS "tenant_invites" (
|
|
"id" text PRIMARY KEY,
|
|
"landlord_id" text REFERENCES "users"("id"),
|
|
"property_id" text REFERENCES "properties"("id"),
|
|
"available_on" bigint,
|
|
"invited_emails" text,
|
|
"created_on" bigint,
|
|
"updated_on" bigint
|
|
);
|
|
|
|
--> statement-breakpoint
|
|
|
|
CREATE INDEX IF NOT EXISTS "tenant_invites_landlord_id_idx"
|
|
ON "tenant_invites" ("landlord_id");
|
|
|
|
CREATE INDEX IF NOT EXISTS "tenant_invites_property_id_idx"
|
|
ON "tenant_invites" ("property_id");
|
|
|
|
CREATE UNIQUE INDEX IF NOT EXISTS "tenant_invites_property_id_unique"
|
|
ON "tenant_invites" ("property_id")
|
|
WHERE "property_id" IS NOT NULL;
|