Eisgnature Migrations, webhook handling, and clean up.

This commit is contained in:
Patrick Fic
2026-03-25 15:24:14 -07:00
parent e17b57c705
commit d4c7298334
23 changed files with 615 additions and 67 deletions

View File

@@ -0,0 +1 @@
DROP TABLE "public"."esignature_documents";

View File

@@ -0,0 +1,18 @@
CREATE TABLE "public"."esignature_documents" ("id" uuid NOT NULL DEFAULT gen_random_uuid(), "created_at" timestamptz NOT NULL DEFAULT now(), "updated_at" timestamptz NOT NULL DEFAULT now(), "external_document_id" text NOT NULL, "jobid" uuid NOT NULL, "status" text NOT NULL, "recipients" jsonb[] NOT NULL, "title" text NOT NULL, "subject" text NOT NULL, "message" text NOT NULL, "viewed" boolean NOT NULL DEFAULT false, "completed" boolean NOT NULL DEFAULT false, "documentid" uuid, "rejected" boolean NOT NULL DEFAULT false, "opened" boolean NOT NULL DEFAULT false, PRIMARY KEY ("id") , FOREIGN KEY ("jobid") REFERENCES "public"."jobs"("id") ON UPDATE restrict ON DELETE restrict);COMMENT ON TABLE "public"."esignature_documents" IS E'Tracking the lifecycle of esignature documents. ';
CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"()
RETURNS TRIGGER AS $$
DECLARE
_new record;
BEGIN
_new := NEW;
_new."updated_at" = NOW();
RETURN _new;
END;
$$ LANGUAGE plpgsql;
CREATE TRIGGER "set_public_esignature_documents_updated_at"
BEFORE UPDATE ON "public"."esignature_documents"
FOR EACH ROW
EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"();
COMMENT ON TRIGGER "set_public_esignature_documents_updated_at" ON "public"."esignature_documents"
IS 'trigger to set value of column "updated_at" to current timestamp on row update';
CREATE EXTENSION IF NOT EXISTS pgcrypto;

View File

@@ -0,0 +1 @@
alter table "public"."esignature_documents" drop constraint "esignature_documents_documentid_fkey";

View File

@@ -0,0 +1,5 @@
alter table "public"."esignature_documents"
add constraint "esignature_documents_documentid_fkey"
foreign key ("documentid")
references "public"."documents"
("id") on update restrict on delete restrict;

View File

@@ -0,0 +1 @@
ALTER TABLE "public"."esignature_documents" ALTER COLUMN "recipients" TYPE ARRAY;

View File

@@ -0,0 +1 @@
ALTER TABLE "public"."esignature_documents" ALTER COLUMN "recipients" TYPE json[];

View File

@@ -0,0 +1,4 @@
-- Could not auto-generate a down migration.
-- Please write an appropriate down migration for the SQL below:
-- alter table "public"."esignature_documents" add column "completed_at" timestamptz
-- null;

View File

@@ -0,0 +1,2 @@
alter table "public"."esignature_documents" add column "completed_at" timestamptz
null;

View File

@@ -0,0 +1,4 @@
comment on column "public"."esignature_documents"."viewed" is E'Tracking the lifecycle of esignature documents. ';
alter table "public"."esignature_documents" alter column "viewed" set default false;
alter table "public"."esignature_documents" alter column "viewed" drop not null;
alter table "public"."esignature_documents" add column "viewed" bool;

View File

@@ -0,0 +1 @@
alter table "public"."esignature_documents" drop column "viewed" cascade;