30 lines · 2.3 KB · Text
RawDownload
CREATE TABLE "membership_tombstones" (	"membership_id" text PRIMARY KEY NOT NULL,	"account_id" text NOT NULL,	"organization_id" text NOT NULL,	"deleted_at" timestamp with time zone DEFAULT now() NOT NULL);--> statement-breakpointCREATE TABLE "workos_sync" (	"id" text PRIMARY KEY NOT NULL,	"cursor" text,	"updated_at" timestamp with time zone DEFAULT now() NOT NULL);--> statement-breakpointALTER TABLE "accounts" ADD COLUMN "email" text;--> statement-breakpointALTER TABLE "accounts" ADD COLUMN "first_name" text;--> statement-breakpointALTER TABLE "accounts" ADD COLUMN "last_name" text;--> statement-breakpointALTER TABLE "accounts" ADD COLUMN "avatar_url" text;--> statement-breakpointALTER TABLE "accounts" ADD COLUMN "workos_updated_at" timestamp with time zone;--> statement-breakpointALTER TABLE "accounts" ADD COLUMN "last_sign_in_at" timestamp with time zone;--> statement-breakpointALTER TABLE "memberships" ADD COLUMN "membership_id" text;--> statement-breakpointALTER TABLE "memberships" ADD COLUMN "role" text DEFAULT 'member' NOT NULL;--> statement-breakpointALTER TABLE "memberships" ADD COLUMN "status" text DEFAULT 'active' NOT NULL;--> statement-breakpointALTER TABLE "memberships" ADD COLUMN "workos_updated_at" timestamp with time zone;--> statement-breakpointALTER TABLE "memberships" ADD COLUMN "deleted_at" timestamp with time zone;--> statement-breakpointALTER TABLE "membership_tombstones" ADD CONSTRAINT "membership_tombstones_account_id_accounts_id_fk" FOREIGN KEY ("account_id") REFERENCES "public"."accounts"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpointALTER TABLE "membership_tombstones" ADD CONSTRAINT "membership_tombstones_organization_id_organizations_id_fk" FOREIGN KEY ("organization_id") REFERENCES "public"."organizations"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpointCREATE INDEX "membership_tombstones_organization_id_idx" ON "membership_tombstones" USING btree ("organization_id");--> statement-breakpointCREATE INDEX "accounts_email_lower_idx" ON "accounts" USING btree (lower("email"));--> statement-breakpointCREATE UNIQUE INDEX "memberships_membership_id_unique" ON "memberships" USING btree ("membership_id");--> statement-breakpointCREATE INDEX "memberships_organization_id_idx" ON "memberships" USING btree ("organization_id");