CREATE TABLE "scanner_inbox_connections" ( "tenant_id" bigint PRIMARY KEY REFERENCES "tenants"("id") ON DELETE CASCADE, "username" text NOT NULL UNIQUE, "password_hash" text NOT NULL, "active" boolean NOT NULL DEFAULT true, "created_at" timestamp with time zone NOT NULL DEFAULT now(), "updated_at" timestamp with time zone ); --> statement-breakpoint CREATE TABLE "scanner_inbox_documents" ( "file_id" uuid PRIMARY KEY REFERENCES "files"("id") ON DELETE CASCADE, "tenant_id" bigint NOT NULL REFERENCES "tenants"("id") ON DELETE CASCADE, "remote_filename" text NOT NULL, "checksum" text NOT NULL, "received_at" timestamp with time zone NOT NULL DEFAULT now() ); --> statement-breakpoint CREATE UNIQUE INDEX "scanner_inbox_documents_filename_key" ON "scanner_inbox_documents" ("tenant_id", "remote_filename"); --> statement-breakpoint CREATE INDEX "scanner_inbox_documents_received_idx" ON "scanner_inbox_documents" ("tenant_id", "received_at");