Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Add diagrams and sql files as architecture documents [DEV-3129] #377

Merged
merged 9 commits into from
Nov 14, 2023

Conversation

lampkin-diet
Copy link
Contributor

No description provided.

@ankurdotb
Copy link
Contributor

@lampkin-diet lampkin-diet changed the title doc: Add diagrams and sql files as architecture documents [DEV-3129] docs: Add diagrams and sql files as architecture documents [DEV-3129] Sep 18, 2023
CREATE TYPE public.categoryenum AS ENUM (
'did',
'resource',
'credential-status'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need a separate credential-status type at all? Is this not just a subset of resource?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need, cause it's mostly list of types which we are handling on CredentialService side. We have only 2 type object on ledger side.

Comment on lines 50 to 80
CREATE TYPE public.namespace AS ENUM (
'testnet',
'mainnet'
);


ALTER TYPE public.namespace OWNER TO veramo;

--
-- Name: namespaceenum; Type: TYPE; Schema: public; Owner: veramo
--

CREATE TYPE public.namespaceenum AS ENUM (
'testnet',
'mainnet'
);


ALTER TYPE public.namespaceenum OWNER TO veramo;

--
-- Name: networkenum; Type: TYPE; Schema: public; Owner: veramo
--

CREATE TYPE public.networkenum AS ENUM (
'testnet',
'mainnet'
);


ALTER TYPE public.networkenum OWNER TO veramo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we're using network at one place and namespace at another, when in practice we could probably just keep one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, we are using only namespaceEnum. Removed all others

Comment on lines 86 to 93
CREATE TYPE public.operationenum AS ENUM (
'create',
'update',
'revoke',
'suspend',
'deactivate',
'reinstate'
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't this supposed to be the method name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's also old type, left from previous variants. We are using operationName as just text field.

Comment on lines +115 to +153
-- Name: claim; Type: TABLE; Schema: public; Owner: veramo
--

CREATE TABLE public.claim (
hash character varying NOT NULL,
"issuanceDate" timestamp without time zone NOT NULL,
"expirationDate" timestamp without time zone,
context text NOT NULL,
"credentialType" text NOT NULL,
value text NOT NULL,
type character varying NOT NULL,
"isObj" boolean NOT NULL,
"issuerDid" character varying,
"subjectDid" character varying,
"credentialHash" character varying NOT NULL,
"customerId" uuid
);


ALTER TABLE public.claim OWNER TO veramo;

--
-- Name: credential; Type: TABLE; Schema: public; Owner: veramo
--

CREATE TABLE public.credential (
hash character varying NOT NULL,
raw text NOT NULL,
id character varying,
"issuanceDate" timestamp without time zone NOT NULL,
"expirationDate" timestamp without time zone,
context text NOT NULL,
type text NOT NULL,
"issuerDid" character varying NOT NULL,
"subjectDid" character varying
);


ALTER TABLE public.credential OWNER TO veramo;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We currently don't store credentials or claims, but these are built-in DBs from Veramo, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, these are from Veramo. Such schema - is a sql-script for the whole database after transformation. That's why here placed all the tables including all from Veramo.

Comment on lines 162 to 163
"createdAt" date NOT NULL,
"updatedAt" date
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timestamp below made me look closer at this. Looks like date only stores the date, without hours/minutes/seconds. Ideally, I want more than just the date, so perhaps can be switch this to timestamp with time zone normalised to UTC?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Switched to timestamptz type instead

Comment on lines 177 to 178
"saveDate" timestamp without time zone NOT NULL,
"updateDate" timestamp without time zone NOT NULL,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how easily we can normalise the Veramo built-in ones to UTC. AFAIK, did-provider-cheqd might already normalise to UTC, which solves the issue for built-in ones.

"resourceId" uuid,
"paymentAddress" character varying NOT NULL,
"operationId" uuid NOT NULL,
"timestamp" date
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see your confusion now :) "Timestamp" as a word in English could refer to date+time or just date, but in Postgres, their interpretation of date and timestamp is different.

Comment on lines 402 to 415
CREATE TABLE public.resource (
"resourceId" uuid NOT NULL,
"identifierDid" character varying NOT NULL,
kid character varying NOT NULL,
"resourceName" character varying NOT NULL,
"resourceType" character varying,
"mediaType" character varying NOT NULL,
"previousVersionId" uuid,
"createdAt" date NOT NULL,
"nextVersionId" uuid,
"customerId" uuid NOT NULL,
"updatedAt" date,
"symmetricKey" character varying
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add encrypted as boolean true/false? This could denote whether the resource is encrypted or not. Since the resourceType on its own does not tell us if the resource is encrypted or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add the explicit field "encrypted" but I was thinking about using symmetricKey field as a marker. If it's empty - resource is unencrypted and vice verse

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added encrypted field for resources into diagrams, images and docs

Comment on lines 490 to 506
-- Data for Name: customer; Type: TABLE DATA; Schema: public; Owner: veramo
--

INSERT INTO public.customer ("customerId", name, "createdAt", "updatedAt") VALUES ('dffb307f-2e61-4e4b-ac64-167ed993800c', 'Sergey', '2023-09-13', NULL);


--
-- Data for Name: identifier; Type: TABLE DATA; Schema: public; Owner: veramo
--



--
-- Data for Name: key; Type: TABLE DATA; Schema: public; Owner: veramo
--

INSERT INTO public.key (kid, kms, type, "publicKeyHex", meta, "identifierDid", "publicKeyAlias", "customerId", "createdAt", "updatedAt") VALUES ('05a0b0b2df2278ec5910042f6bf5fe7ee9009102b9c6dab5d43745e96a14f5f66ff96b9a654793cb95895eef700f0903f030966802b48247294abe3c583dd221b0', 'postgres', 'Ed25519', '05a0b0b2df2278ec5910042f6bf5fe7ee9009102b9c6dab5d43745e96a14f5f66ff96b9a654793cb95895eef700f0903f030966802b48247294abe3c583dd221b0', '{"algorithms":["ES256K","ES256K-R","eth_signTransaction","eth_signTypedData","eth_signMessage","eth_rawSign"]}', NULL, 'SergeyKey', 'dffb307f-2e61-4e4b-ac64-167ed993800c', '2023-09-13', NULL);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like test data?

Comment on lines +610 to +708
ALTER TABLE ONLY public.message_credentials_credential
ADD CONSTRAINT "PK_1f64a9d131c0f7245a90deee93f" PRIMARY KEY ("messageId", "credentialHash");


--
-- Name: presentation_credentials_credential PK_32d9cee791ee1139f29fd94b5c4; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public.presentation_credentials_credential
ADD CONSTRAINT "PK_32d9cee791ee1139f29fd94b5c4" PRIMARY KEY ("presentationHash", "credentialHash");


--
-- Name: credential PK_32ea339ef30d340caac7961bd44; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public.credential
ADD CONSTRAINT "PK_32ea339ef30d340caac7961bd44" PRIMARY KEY (hash);


--
-- Name: service PK_85a21558c006647cd76fdce044b; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public.service
ADD CONSTRAINT "PK_85a21558c006647cd76fdce044b" PRIMARY KEY (id);


--
-- Name: presentation PK_8731bc1d6170def561c4820364b; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public.presentation
ADD CONSTRAINT "PK_8731bc1d6170def561c4820364b" PRIMARY KEY (hash);


--
-- Name: private-key PK_87ac66202b01336a9df721d4ed8; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public."private-key"
ADD CONSTRAINT "PK_87ac66202b01336a9df721d4ed8" PRIMARY KEY (alias);


--
-- Name: migrations PK_8c82d7f526340ab734260ea46be; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public.migrations
ADD CONSTRAINT "PK_8c82d7f526340ab734260ea46be" PRIMARY KEY (id);


--
-- Name: key PK_9bda40833be3c080825245b1a11; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public.key
ADD CONSTRAINT "PK_9bda40833be3c080825245b1a11" PRIMARY KEY (kid);


--
-- Name: message_presentations_presentation PK_9dc4cc025ec7163ec5ca919d140; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public.message_presentations_presentation
ADD CONSTRAINT "PK_9dc4cc025ec7163ec5ca919d140" PRIMARY KEY ("messageId", "presentationHash");


--
-- Name: identifier PK_a1ec7926e246e12a63e377e592e; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public.identifier
ADD CONSTRAINT "PK_a1ec7926e246e12a63e377e592e" PRIMARY KEY (did);


--
-- Name: message PK_ba01f0a3e0123651915008bc578; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public.message
ADD CONSTRAINT "PK_ba01f0a3e0123651915008bc578" PRIMARY KEY (id);


--
-- Name: presentation_verifier_identifier PK_c3b760612b992bc75511d74f6a9; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public.presentation_verifier_identifier
ADD CONSTRAINT "PK_c3b760612b992bc75511d74f6a9" PRIMARY KEY ("presentationHash", "identifierDid");


--
-- Name: claim PK_d8d95bd745ab41510c724a43c36; Type: CONSTRAINT; Schema: public; Owner: veramo
--

ALTER TABLE ONLY public.claim
ADD CONSTRAINT "PK_d8d95bd745ab41510c724a43c36" PRIMARY KEY (hash);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand, these are references to a specific table and not relevant outside of it.

@lampkin-diet lampkin-diet merged commit 56f4675 into develop Nov 14, 2023
7 checks passed
@lampkin-diet lampkin-diet deleted the DEV-3129 branch November 14, 2023 14:52
@cheqd-bot
Copy link

cheqd-bot bot commented Dec 8, 2023

🎉 This PR is included in version 2.12.0-develop.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@cheqd-bot
Copy link

cheqd-bot bot commented Dec 20, 2023

🎉 This PR is included in version 2.12.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@cheqd-bot cheqd-bot bot added the released label Dec 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

2 participants