From 9f340c3945ee7a921b002523a7936d3696c9b6c9 Mon Sep 17 00:00:00 2001 From: jojo aquino Date: Sun, 20 Apr 2025 08:59:51 +0100 Subject: [PATCH 01/14] configure and implement DbUp related stuff --- .../EnotaryoPH.DbMigration.csproj | 34 + EnotaryoPH/EnotaryoPH.DbMigration/Program.cs | 59 ++ .../Scripts/01_Schema.sql | 715 ++++++++++++++++++ .../Scripts/02_SeedLookupData.sql | 74 ++ EnotaryoPH/EnotaryoPH.sln | 6 + 5 files changed, 888 insertions(+) create mode 100644 EnotaryoPH/EnotaryoPH.DbMigration/EnotaryoPH.DbMigration.csproj create mode 100644 EnotaryoPH/EnotaryoPH.DbMigration/Program.cs create mode 100644 EnotaryoPH/EnotaryoPH.DbMigration/Scripts/01_Schema.sql create mode 100644 EnotaryoPH/EnotaryoPH.DbMigration/Scripts/02_SeedLookupData.sql diff --git a/EnotaryoPH/EnotaryoPH.DbMigration/EnotaryoPH.DbMigration.csproj b/EnotaryoPH/EnotaryoPH.DbMigration/EnotaryoPH.DbMigration.csproj new file mode 100644 index 0000000..e954aa9 --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.DbMigration/EnotaryoPH.DbMigration.csproj @@ -0,0 +1,34 @@ + + + + Exe + net9.0 + enable + enable + d6cabec2-f14e-40aa-b2ef-90a832d8e1e4 + + + + + + + + + + + + + + + + + + + + + + PreserveNewest + + + + diff --git a/EnotaryoPH/EnotaryoPH.DbMigration/Program.cs b/EnotaryoPH/EnotaryoPH.DbMigration/Program.cs new file mode 100644 index 0000000..9b95e04 --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.DbMigration/Program.cs @@ -0,0 +1,59 @@ +using System.Reflection; +using DbUp; +using Microsoft.Extensions.Configuration; + +namespace EnotaryoPH.DbMigration +{ + internal class Program + { + private static int Main(string[] args) + { + Console.ForegroundColor = ConsoleColor.Yellow; + + var config = new ConfigurationBuilder() + .AddJsonFile("appsettings.json") + .Build(); + var connectionString = + args.FirstOrDefault() + ?? config.GetConnectionString("DbUpConnection"); + + Console.WriteLine($"Connecting to {connectionString}"); + + var upgrader = + DeployChanges.To + .PostgresqlDatabase(connectionString) + .WithVariablesDisabled() + .WithScriptsEmbeddedInAssembly(Assembly.GetExecutingAssembly()) + .LogToConsole() + .Build(); + + if (upgrader.TryConnect(out var err)) + { + var result = upgrader.PerformUpgrade(); + + if (!result.Successful) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(result.Error); + Console.ResetColor(); +#if DEBUG + Console.ReadLine(); +#endif + return -1; + } + } + else + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine($"Cannot Connect: '{err}'"); + Console.ResetColor(); + return -1; + } + + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("Success!"); + Console.ResetColor(); + return 0; + } + } +} \ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/01_Schema.sql b/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/01_Schema.sql new file mode 100644 index 0000000..3ae833c --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/01_Schema.sql @@ -0,0 +1,715 @@ + + +CREATE EXTENSION if not EXISTS "uuid-ossp" + SCHEMA "public" + VERSION "1.1"; + + +-- DROP SCHEMA public; + +CREATE SCHEMA IF NOT EXISTS public AUTHORIZATION pg_database_owner; + +-- DROP SEQUENCE "LawyerVideoConferenceParticip_LawyerVideoConferenceParticip_seq"; + +CREATE SEQUENCE "LawyerVideoConferenceParticip_LawyerVideoConferenceParticip_seq" + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE "LawyerVideoConferenceSchedule_LawyerVideoConferenceSchedule_seq"; + +CREATE SEQUENCE "LawyerVideoConferenceSchedule_LawyerVideoConferenceSchedule_seq" + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE "LookupDataValues_LookupDataValueID_seq"; + +CREATE SEQUENCE "LookupDataValues_LookupDataValueID_seq" + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE "LookupData_LookupDataID_seq"; + +CREATE SEQUENCE "LookupData_LookupDataID_seq" + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE "TransactionDeclineReasons_TransactionDeclineReasonID_seq"; + +CREATE SEQUENCE "TransactionDeclineReasons_TransactionDeclineReasonID_seq" + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE "TransactionSelfies_TransactionSelfieID_seq"; + +CREATE SEQUENCE "TransactionSelfies_TransactionSelfieID_seq" + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE "TransactionSignatoryDeclineRe_TransactionSignatoryDeclineRe_seq"; + +CREATE SEQUENCE "TransactionSignatoryDeclineRe_TransactionSignatoryDeclineRe_seq" + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE "VideoRecordings_VideoRecordingID_seq"; + +CREATE SEQUENCE "VideoRecordings_VideoRecordingID_seq" + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE errorlogs_errorlogid_seq; + +CREATE SEQUENCE errorlogs_errorlogid_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE eventlogs_eventlogid_seq; + +CREATE SEQUENCE eventlogs_eventlogid_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE identificationdocuments_identificationdocumentid_seq; + +CREATE SEQUENCE identificationdocuments_identificationdocumentid_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE lawyers_lawyerid_seq; + +CREATE SEQUENCE lawyers_lawyerid_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE templates_templateid_seq; + +CREATE SEQUENCE templates_templateid_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 2147483647 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE transactiondocuments_transactiondocumentid_seq; + +CREATE SEQUENCE transactiondocuments_transactiondocumentid_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE transactionnotary_transactionnotaryid_seq; + +CREATE SEQUENCE transactionnotary_transactionnotaryid_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE transactionotp_transactionotpid_seq; + +CREATE SEQUENCE transactionotp_transactionotpid_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE transactions_transactionid_seq; + +CREATE SEQUENCE transactions_transactionid_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE transactionsignatories_transactionsignatoryid_seq; + +CREATE SEQUENCE transactionsignatories_transactionsignatoryid_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE; +-- DROP SEQUENCE users_userid_seq; + +CREATE SEQUENCE users_userid_seq + INCREMENT BY 1 + MINVALUE 1 + MAXVALUE 9223372036854775807 + START 1 + CACHE 1 + NO CYCLE;-- public."ErrorLogs" definition + +-- Drop table + +-- DROP TABLE "ErrorLogs"; + +CREATE TABLE "ErrorLogs" ( + "ErrorLogID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "Message" varchar NOT NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "Severity" varchar NULL, + "Exception" varchar NULL, + "Stacktrace" varchar NULL, + "ErrorLog_UID" uuid DEFAULT uuid_generate_v4() NULL, + CONSTRAINT errorlogs_pk PRIMARY KEY ("ErrorLogID") +); +CREATE INDEX "ErrorLogs_CreatedOn_IDX" ON public."ErrorLogs" USING btree ("CreatedOn" DESC); +CREATE UNIQUE INDEX "ErrorLogs_ErrorLog_UID_IDX" ON public."ErrorLogs" USING btree ("ErrorLog_UID"); + + +-- public."LookupData" definition + +-- Drop table + +-- DROP TABLE "LookupData"; + +CREATE TABLE "LookupData" ( + "LookupDataID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "LookupData_UID" uuid DEFAULT uuid_generate_v4() NOT NULL, + "Category" varchar NULL, + "ParentCategory" varchar NULL, + "Name" varchar NOT NULL, + "Description" varchar NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + CONSTRAINT "LookupData_pk" PRIMARY KEY ("LookupDataID"), + CONSTRAINT "LookupData_unique" UNIQUE ("LookupData_UID") +); +CREATE UNIQUE INDEX "LookupData_Name_Category_IDX" ON public."LookupData" USING btree ("Name", "Category"); + + +-- public."Templates" definition + +-- Drop table + +-- DROP TABLE "Templates"; + +CREATE TABLE "Templates" ( + "TemplateID" int4 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 2147483647 START 1 CACHE 1 NO CYCLE) NOT NULL, + "Name" varchar NOT NULL, + "Description" varchar NULL, + "Pagecount" int4 NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "TemplateUrl" varchar NULL, + "Template_UID" uuid DEFAULT uuid_generate_v4() NULL, + CONSTRAINT templates_pk PRIMARY KEY ("TemplateID") +); + + +-- public."Users" definition + +-- Drop table + +-- DROP TABLE "Users"; + +CREATE TABLE "Users" ( + "UserID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "Email" varchar NOT NULL, + "PasswordHash" varchar NOT NULL, + "PhoneNumber" varchar NULL, + "Firstname" varchar NULL, + "Lastname" varchar NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "User_UID" uuid DEFAULT uuid_generate_v4() NULL, + "Role" varchar DEFAULT 'user'::character varying NULL, + "BirthDate" date NOT NULL, + "Middlename" varchar NULL, + "Suffix" varchar NULL, + "Prefix" varchar NULL, + CONSTRAINT users_pk PRIMARY KEY ("UserID"), + CONSTRAINT users_unique_email UNIQUE ("Email"), + CONSTRAINT users_unique_uid UNIQUE ("User_UID") +); + + +-- public."EventLogs" definition + +-- Drop table + +-- DROP TABLE "EventLogs"; + +CREATE TABLE "EventLogs" ( + "EventLogID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "StreamID" int8 NOT NULL, + "LogType" varchar NOT NULL, + "LogDate" time DEFAULT now() NULL, + "UserID" int8 NULL, + "Payload" varchar NOT NULL, + "Description" varchar NULL, + "EventLog_UID" uuid DEFAULT uuid_generate_v4() NULL, + CONSTRAINT eventlogs_pk PRIMARY KEY ("EventLogID"), + CONSTRAINT eventlogs_users_fk FOREIGN KEY ("UserID") REFERENCES "Users"("UserID") +); +CREATE UNIQUE INDEX "EventLogs_EventLog_UID_IDX" ON public."EventLogs" USING btree ("EventLog_UID"); +CREATE INDEX "EventLogs_LogDate_IDX" ON public."EventLogs" USING btree ("LogDate" DESC); +CREATE INDEX "EventLogs_StreamID_IDX" ON public."EventLogs" USING btree ("StreamID"); +CREATE INDEX "EventLogs_UserID_IDX" ON public."EventLogs" USING btree ("UserID"); + + +-- public."IdentificationDocuments" definition + +-- Drop table + +-- DROP TABLE "IdentificationDocuments"; + +CREATE TABLE "IdentificationDocuments" ( + "IdentificationDocumentID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "Type" varchar NOT NULL, + "ExpirationDate" date NOT NULL, + "Filename" varchar NOT NULL, + "File" bytea NOT NULL, + "UserID" int8 NOT NULL, + "IdNumber" varchar NOT NULL, + "PlaceIssued" varchar NOT NULL, + "DateIssued" date NOT NULL, + "CreatedOn" timestamp DEFAULT now() NOT NULL, + "IdentificationDocument_UID" uuid DEFAULT uuid_generate_v4() NOT NULL, + "IsDeleted" bool NULL, + "UploadedOn" timestamp NOT NULL, + CONSTRAINT identificationdocuments_pk PRIMARY KEY ("IdentificationDocumentID"), + CONSTRAINT identificationdocuments_users_fk FOREIGN KEY ("UserID") REFERENCES "Users"("UserID") +); +CREATE UNIQUE INDEX "IdentificationDocuments_IdentificationDocument_UID_IDX" ON public."IdentificationDocuments" USING btree ("IdentificationDocument_UID"); + + +-- public."Lawyers" definition + +-- Drop table + +-- DROP TABLE "Lawyers"; + +CREATE TABLE "Lawyers" ( + "LawyerID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "Rollnumber" varchar NULL, + "IBPNumber" varchar NULL, + "MCLEComplianceNumber" varchar NULL, + "MCLEDate" date NULL, + "PTRNumber" varchar NULL, + "PTRDate" date NULL, + "PTRlocation" varchar NULL, + "OfficeAddress" varchar NULL, + "UserID" int8 NOT NULL, + "Lawyer_UID" uuid DEFAULT uuid_generate_v4() NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "CommissionNumber" varchar NULL, + "CommissionLocation" varchar NULL, + "CommissionExpiration" date NULL, + "Status" varchar DEFAULT 'Registered'::character varying NULL, + CONSTRAINT lawyers_pk PRIMARY KEY ("LawyerID"), + CONSTRAINT lawyers_users_fk FOREIGN KEY ("UserID") REFERENCES "Users"("UserID") +); + + +-- public."LookupDataValues" definition + +-- Drop table + +-- DROP TABLE "LookupDataValues"; + +CREATE TABLE "LookupDataValues" ( + "LookupDataValueID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "LookupDataValue_UID" uuid DEFAULT uuid_generate_v4() NOT NULL, + "LookupDataID" int8 NULL, + "Value" varchar NOT NULL, + "Title" varchar NULL, + "SortOrder" int4 NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + CONSTRAINT "LookupDataValues_pk" PRIMARY KEY ("LookupDataValueID"), + CONSTRAINT "LookupDataValues_unique" UNIQUE ("LookupDataValue_UID"), + CONSTRAINT "LookupDataValues_LookupData_FK" FOREIGN KEY ("LookupDataID") REFERENCES "LookupData"("LookupDataID") +); + + +-- public."Transactions" definition + +-- Drop table + +-- DROP TABLE "Transactions"; + +CREATE TABLE "Transactions" ( + "TransactionID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "TransactionDate" date NOT NULL, + "PrincipalID" int8 NOT NULL, + "Status" varchar NOT NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "Transaction_UID" uuid DEFAULT uuid_generate_v4() NULL, + "PreferredLawyerID" int8 NULL, + "LawyerID" int8 NULL, + "IsRecorded" bool NULL, + CONSTRAINT transactions_pk PRIMARY KEY ("TransactionID"), + CONSTRAINT "Transactions_Lawyers_FK" FOREIGN KEY ("LawyerID") REFERENCES "Lawyers"("LawyerID"), + CONSTRAINT "Transactions_PreferredLawyers_FK" FOREIGN KEY ("PreferredLawyerID") REFERENCES "Lawyers"("LawyerID"), + CONSTRAINT "Transactions_Users_FK" FOREIGN KEY ("PrincipalID") REFERENCES "Users"("UserID") +); +CREATE INDEX "Transactions_TransactionDate_IDX" ON public."Transactions" USING btree ("TransactionDate" DESC); +CREATE UNIQUE INDEX "Transactions_Transaction_UID_IDX" ON public."Transactions" USING btree ("Transaction_UID"); + + +-- public."LawyerVideoConferenceSchedule" definition + +-- Drop table + +-- DROP TABLE "LawyerVideoConferenceSchedule"; + +CREATE TABLE "LawyerVideoConferenceSchedule" ( + "LawyerVideoConferenceScheduleID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "LawyerID" int8 NOT NULL, + "TransactionID" int8 NOT NULL, + "MeetingDate" timestamp NOT NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "LawyerVideoConferenceSchedule_UID" uuid DEFAULT uuid_generate_v4() NULL, + "Status" varchar NULL, + "MeetingRoomID" varchar NULL, + "MeetingRoomTokenID" varchar NULL, + "MeetingRoomUserID" varchar NULL, + "ServerCallID" varchar NULL, + "RecordingID" varchar NULL, + CONSTRAINT "LawyerVideoConferenceSchedule_pk" PRIMARY KEY ("LawyerVideoConferenceScheduleID"), + CONSTRAINT "LawyerVideoConferenceSchedule_unique" UNIQUE ("LawyerVideoConferenceSchedule_UID"), + CONSTRAINT "LawyerVideoConferenceSchedule_Lawyers_FK" FOREIGN KEY ("LawyerID") REFERENCES "Lawyers"("LawyerID"), + CONSTRAINT "LawyerVideoConferenceSchedule_Transactions_FK" FOREIGN KEY ("TransactionID") REFERENCES "Transactions"("TransactionID") +); +CREATE INDEX "LawyerVideoConferenceSchedule_RecordingID_IDX" ON public."LawyerVideoConferenceSchedule" USING btree ("RecordingID"); +CREATE INDEX "LawyerVideoConferenceSchedule_TransactionID_IDX" ON public."LawyerVideoConferenceSchedule" USING btree ("TransactionID"); + + +-- public."TransactionDeclineReasons" definition + +-- Drop table + +-- DROP TABLE "TransactionDeclineReasons"; + +CREATE TABLE "TransactionDeclineReasons" ( + "TransactionDeclineReasonID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "TransactionID" int8 NOT NULL, + "Reason" varchar NOT NULL, + "LawyerID" int8 NOT NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "TransactionDeclineReason_UID" uuid DEFAULT uuid_generate_v4() NULL, + CONSTRAINT "TransactionDeclineReasons_pk" PRIMARY KEY ("TransactionDeclineReasonID"), + CONSTRAINT "TransactionDeclineReasons_Lawyers_FK" FOREIGN KEY ("LawyerID") REFERENCES "Lawyers"("LawyerID"), + CONSTRAINT "TransactionDeclineReasons_Transactions_FK" FOREIGN KEY ("TransactionID") REFERENCES "Transactions"("TransactionID") +); +CREATE UNIQUE INDEX "TransactionDeclineReasons_TransactionDeclineReason_UID_IDX" ON public."TransactionDeclineReasons" USING btree ("TransactionDeclineReason_UID"); + + +-- public."TransactionDocuments" definition + +-- Drop table + +-- DROP TABLE "TransactionDocuments"; + +CREATE TABLE "TransactionDocuments" ( + "TransactionDocumentID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "TransactionID" int8 NOT NULL, + "Filename" varchar NOT NULL, + "Notes" varchar NULL, + "File" bytea NOT NULL, + "UploadedOn" timestamp NOT NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "TransactionDocument_UID" uuid DEFAULT uuid_generate_v4() NULL, + "DocumentType" varchar NOT NULL, + CONSTRAINT transactiondocuments_pk PRIMARY KEY ("TransactionDocumentID"), + CONSTRAINT transactiondocuments_transactions_fk FOREIGN KEY ("TransactionID") REFERENCES "Transactions"("TransactionID") +); + + +-- public."TransactionNotary" definition + +-- Drop table + +-- DROP TABLE "TransactionNotary"; + +CREATE TABLE "TransactionNotary" ( + "TransactionNotaryID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "TransactionID" int8 NOT NULL, + "DocNumber" varchar NULL, + "BookNumber" varchar NULL, + "PageNumber" varchar NULL, + "Series" varchar NULL, + "SignedOn" date NULL, + "Remarks" varchar NULL, + "LawyerID" int8 NOT NULL, + "CertificateType" varchar NULL, + "TemplateID" int4 NULL, + "PageCount" int4 NULL, + "TransactionNotary_UID" uuid DEFAULT uuid_generate_v4() NULL, + CONSTRAINT transactionnotary_pk PRIMARY KEY ("TransactionNotaryID"), + CONSTRAINT transactionnotary_lawyers_fk FOREIGN KEY ("LawyerID") REFERENCES "Lawyers"("LawyerID"), + CONSTRAINT transactionnotary_templates_fk FOREIGN KEY ("TemplateID") REFERENCES "Templates"("TemplateID"), + CONSTRAINT transactionnotary_transactions_fk FOREIGN KEY ("TransactionID") REFERENCES "Transactions"("TransactionID") +); + + +-- public."TransactionOTP" definition + +-- Drop table + +-- DROP TABLE "TransactionOTP"; + +CREATE TABLE "TransactionOTP" ( + "TransactionOTPID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "TransactionID" int8 NOT NULL, + "VerifiedOn" time NOT NULL, + "PrintCoords" varchar NOT NULL, + "Status" varchar NOT NULL, + "UserID" int8 NOT NULL, + "TransactionOTP_UID" uuid DEFAULT uuid_generate_v4() NULL, + "OTPHash" varchar NOT NULL, + "OTPUserInput" varchar NULL, + "IPAddress" varchar NULL, + "Longitude" numeric NULL, + "Lattitude" numeric NULL, + "Device" varchar NULL, + "File_Liveness" bytea NULL, + CONSTRAINT transactionotp_pk PRIMARY KEY ("TransactionOTPID"), + CONSTRAINT "TransactionOTP_Users_FK" FOREIGN KEY ("UserID") REFERENCES "Users"("UserID"), + CONSTRAINT transactionotp_transactions_fk FOREIGN KEY ("TransactionID") REFERENCES "Transactions"("TransactionID") +); +CREATE INDEX "TransactionOTP_TransactionID_IDX" ON public."TransactionOTP" USING btree ("TransactionID"); +CREATE UNIQUE INDEX "TransactionOTP_TransactionOTP_UID_IDX" ON public."TransactionOTP" USING btree ("TransactionOTP_UID"); + + +-- public."TransactionSelfies" definition + +-- Drop table + +-- DROP TABLE "TransactionSelfies"; + +CREATE TABLE "TransactionSelfies" ( + "TransactionSelfieID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "TransactionID" int8 NULL, + "IdentificationDocumentID" int8 NULL, + "File" bytea NOT NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "TransactionSelfie_UID" uuid DEFAULT uuid_generate_v4() NULL, + "UserID" int8 NOT NULL, + CONSTRAINT "TransactionSelfies_pk" PRIMARY KEY ("TransactionSelfieID"), + CONSTRAINT "TransactionSelfies_IdentificationDocuments_FK" FOREIGN KEY ("IdentificationDocumentID") REFERENCES "IdentificationDocuments"("IdentificationDocumentID"), + CONSTRAINT "TransactionSelfies_Transactions_FK" FOREIGN KEY ("TransactionID") REFERENCES "Transactions"("TransactionID"), + CONSTRAINT "TransactionSelfies_Users_FK" FOREIGN KEY ("UserID") REFERENCES "Users"("UserID") +); +CREATE UNIQUE INDEX "TransactionSelfies_TransactionSelfie_UID_IDX" ON public."TransactionSelfies" USING btree ("TransactionSelfie_UID"); + + +-- public."TransactionSignatories" definition + +-- Drop table + +-- DROP TABLE "TransactionSignatories"; + +CREATE TABLE "TransactionSignatories" ( + "TransactionSignatoryID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "TransactionID" int8 NOT NULL, + "UserID" int8 NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "Status" varchar NOT NULL, + "Email" varchar NOT NULL, + "Type" varchar NOT NULL, + "TransactionSignatory_UID" uuid DEFAULT uuid_generate_v4() NULL, + "InvitationCode" varchar NOT NULL, + CONSTRAINT transactionsignatories_pk PRIMARY KEY ("TransactionSignatoryID"), + CONSTRAINT transactionsignatories_transactions_fk FOREIGN KEY ("TransactionID") REFERENCES "Transactions"("TransactionID"), + CONSTRAINT transactionsignatories_users_fk FOREIGN KEY ("UserID") REFERENCES "Users"("UserID") +); +CREATE INDEX "TransactionSignatories_InvitationCode_IDX" ON public."TransactionSignatories" USING btree ("InvitationCode"); +CREATE INDEX "TransactionSignatories_TransactionID_IDX" ON public."TransactionSignatories" USING btree ("TransactionID", "Email"); +CREATE UNIQUE INDEX "TransactionSignatories_TransactionSignatory_UID_IDX" ON public."TransactionSignatories" USING btree ("TransactionSignatory_UID"); + + +-- public."TransactionSignatoryDeclineReasons" definition + +-- Drop table + +-- DROP TABLE "TransactionSignatoryDeclineReasons"; + +CREATE TABLE "TransactionSignatoryDeclineReasons" ( + "TransactionSignatoryDeclineReasonID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "UserID" int8 NOT NULL, + "DeclineReason" varchar NOT NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "TransactionSignatoryDeclineReason_UID" uuid DEFAULT uuid_generate_v4() NOT NULL, + "TransactionID" int8 NOT NULL, + "TransactionSignatoryID" int8 NULL, + CONSTRAINT "TransactionSignatoryDeclineReasons_pk" PRIMARY KEY ("TransactionSignatoryDeclineReasonID"), + CONSTRAINT "TransactionSignatoryDeclineReasons_unique" UNIQUE ("TransactionSignatoryDeclineReason_UID"), + CONSTRAINT "TransactionSignatoryDeclineReasons_TransactionSignatories_FK" FOREIGN KEY ("TransactionSignatoryID") REFERENCES "TransactionSignatories"("TransactionSignatoryID"), + CONSTRAINT "TransactionSignatoryDeclineReasons_Users_FK" FOREIGN KEY ("UserID") REFERENCES "Users"("UserID") +); +CREATE INDEX "TransactionSignatoryDeclineReasons_UserID_IDX" ON public."TransactionSignatoryDeclineReasons" USING btree ("UserID", "TransactionID"); + + +-- public."VideoRecordings" definition + +-- Drop table + +-- DROP TABLE "VideoRecordings"; + +CREATE TABLE "VideoRecordings" ( + "VideoRecordingID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "VideoConferenceScheduleID" int8 NOT NULL, + "Path" varchar NOT NULL, + "LocationType" varchar NOT NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "VideoRecording_UID" uuid DEFAULT uuid_generate_v4() NULL, + CONSTRAINT "VideoRecordings_pk" PRIMARY KEY ("VideoRecordingID"), + CONSTRAINT "VideoRecordings_unique" UNIQUE ("VideoConferenceScheduleID"), + CONSTRAINT "VideoRecordings_unique_UID" UNIQUE ("VideoRecording_UID"), + CONSTRAINT "VideoRecordings_LawyerVideoConferenceSchedule_FK" FOREIGN KEY ("VideoConferenceScheduleID") REFERENCES "LawyerVideoConferenceSchedule"("LawyerVideoConferenceScheduleID") +); + + +-- public."LawyerVideoConferenceParticipants" definition + +-- Drop table + +-- DROP TABLE "LawyerVideoConferenceParticipants"; + +CREATE TABLE "LawyerVideoConferenceParticipants" ( + "LawyerVideoConferenceParticipantID" int8 GENERATED ALWAYS AS IDENTITY( INCREMENT BY 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1 NO CYCLE) NOT NULL, + "LawyerVideoConferenceScheduleID" int8 NOT NULL, + "ParticipantID" int8 NOT NULL, + "Status" varchar NULL, + "CreatedOn" timestamp DEFAULT now() NULL, + "LawyerVideoConferenceParticipant_UID" uuid DEFAULT uuid_generate_v4() NULL, + "MeetingRoomTokenID" varchar NULL, + "MeetingRoomUserID" varchar NULL, + CONSTRAINT "LawyerVideoConferenceParticipants_pk" PRIMARY KEY ("LawyerVideoConferenceParticipantID"), + CONSTRAINT "LawyerVideoConferenceParticipants_LawyerVideoConferenceSchedule" FOREIGN KEY ("LawyerVideoConferenceScheduleID") REFERENCES "LawyerVideoConferenceSchedule"("LawyerVideoConferenceScheduleID"), + CONSTRAINT "LawyerVideoConferenceParticipants_Users_FK" FOREIGN KEY ("ParticipantID") REFERENCES "Users"("UserID") +); +CREATE UNIQUE INDEX "LawyerVideoConferenceParticipants_LawyerVideoConferenceParticip" ON public."LawyerVideoConferenceParticipants" USING btree ("LawyerVideoConferenceParticipant_UID"); +CREATE UNIQUE INDEX "LawyerVideoConferenceParticipants_LawyerVideoConferenceSchedule" ON public."LawyerVideoConferenceParticipants" USING btree ("LawyerVideoConferenceScheduleID", "ParticipantID"); + + + +-- DROP FUNCTION public.uuid_generate_v1(); + +CREATE OR REPLACE FUNCTION public.uuid_generate_v1() + RETURNS uuid + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_generate_v1$function$ +; + +-- DROP FUNCTION public.uuid_generate_v1mc(); + +CREATE OR REPLACE FUNCTION public.uuid_generate_v1mc() + RETURNS uuid + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_generate_v1mc$function$ +; + +-- DROP FUNCTION public.uuid_generate_v3(uuid, text); + +CREATE OR REPLACE FUNCTION public.uuid_generate_v3(namespace uuid, name text) + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_generate_v3$function$ +; + +-- DROP FUNCTION public.uuid_generate_v4(); + +CREATE OR REPLACE FUNCTION public.uuid_generate_v4() + RETURNS uuid + LANGUAGE c + PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_generate_v4$function$ +; + +-- DROP FUNCTION public.uuid_generate_v5(uuid, text); + +CREATE OR REPLACE FUNCTION public.uuid_generate_v5(namespace uuid, name text) + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_generate_v5$function$ +; + +-- DROP FUNCTION public.uuid_nil(); + +CREATE OR REPLACE FUNCTION public.uuid_nil() + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_nil$function$ +; + +-- DROP FUNCTION public.uuid_ns_dns(); + +CREATE OR REPLACE FUNCTION public.uuid_ns_dns() + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_ns_dns$function$ +; + +-- DROP FUNCTION public.uuid_ns_oid(); + +CREATE OR REPLACE FUNCTION public.uuid_ns_oid() + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_ns_oid$function$ +; + +-- DROP FUNCTION public.uuid_ns_url(); + +CREATE OR REPLACE FUNCTION public.uuid_ns_url() + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_ns_url$function$ +; + +-- DROP FUNCTION public.uuid_ns_x500(); + +CREATE OR REPLACE FUNCTION public.uuid_ns_x500() + RETURNS uuid + LANGUAGE c + IMMUTABLE PARALLEL SAFE STRICT +AS '$libdir/uuid-ossp', $function$uuid_ns_x500$function$ +; \ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/02_SeedLookupData.sql b/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/02_SeedLookupData.sql new file mode 100644 index 0000000..9a329fd --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/02_SeedLookupData.sql @@ -0,0 +1,74 @@ +DO $$ + +DECLARE doc_type_id INTEGER; +DECLARE id_type_id INTEGER; + +BEGIN + + INSERT INTO "LookupData" ("Name") + VALUES + ('Document Types'), + ('Identification Types'); + + + + SELECT "LookupDataID" INTO doc_type_id FROM "LookupData" WHERE "Name" = 'Document Types' LIMIT 1; + + -- Now insert into LookupDataValues using the retrieved ID + INSERT INTO "LookupDataValues" ("LookupDataID", "Value") + VALUES (doc_type_id, 'Affidavit of Acknowledgement of a Child'), + (doc_type_id, 'Affidavit of Undertaking'), + (doc_type_id, 'Affidavit of service'), + (doc_type_id, 'Affidavits'), + (doc_type_id, 'Bid docs'), + (doc_type_id, 'Biodata'), + (doc_type_id, 'Certification against non-forum shopping'), + (doc_type_id, 'Certification of Compliance Officer'), + (doc_type_id, 'Contract of Lease'), + (doc_type_id, 'Deed of Absolute Sale'), + (doc_type_id, 'Deed of Assignment'), + (doc_type_id, 'Extrajudicial Partition'), + (doc_type_id, 'FCFS/LCFS'), + (doc_type_id, 'FCIF/LCIF'), + (doc_type_id, 'GIS'), + (doc_type_id, 'LGU business permit application form'), + (doc_type_id, 'Loan Agreement'), + (doc_type_id, 'Personal Data Sheet'), + (doc_type_id, 'Proxy forms'), + (doc_type_id, 'Quitclaims'), + (doc_type_id, 'SALN'), + (doc_type_id, 'Secretary’s Certificate'), + (doc_type_id, 'Service Agreements'), + (doc_type_id, 'Settlement Agreement'), + (doc_type_id, 'Special Power of Attorney'), + (doc_type_id, 'Verification of pleadings'), + (doc_type_id, 'Wills'); + + SELECT "LookupDataID" INTO id_type_id FROM "LookupData" WHERE "Name" = 'Identification Types' LIMIT 1; + + -- Now insert into LookupDataValues using the retrieved ID + INSERT INTO "LookupDataValues" ("LookupDataID", "Value") + VALUES (id_type_id, 'Administration (OWWA) ID'), + (id_type_id, 'Alien Certificate of Registration'), + (id_type_id, 'Certification from the National Council for the Welfare of Disabled Persons (NCWDP)'), + (id_type_id, 'Department of Social Welfare and Development (DSWD) certification'), + (id_type_id, 'Driver''s license'), + (id_type_id, 'Government Office ID'), + (id_type_id, 'Government Service and Insurance System (GSIS) e-card'), + (id_type_id, 'Immigrant Certificate of Registration'), + (id_type_id, 'Integrated Bar of the Philippines (IBP) ID'), + (id_type_id, 'National Bureau of Investigation (NBI) clearance'), + (id_type_id, 'Overseas Filipino Worker (OFW) ID'), + (id_type_id, 'Overseas Workers Welfare Administration (OWWA) ID'), + (id_type_id, 'Passport'), + (id_type_id, 'PhilHealth card'), + (id_type_id, 'Police clearance'), + (id_type_id, 'Postal ID'), + (id_type_id, 'Professional Regulations Commission (PRC) ID'), + (id_type_id, 'Seaman''s book'), + (id_type_id, 'Senior citizen card'), + (id_type_id, 'Social Security System (SSS) card'), + (id_type_id, 'Tax Identification Number (TIN) ID'), + (id_type_id, 'Unified Multi-Purpose ID (UMID) Card'), + (id_type_id, 'Voter''s ID'); +END $$; diff --git a/EnotaryoPH/EnotaryoPH.sln b/EnotaryoPH/EnotaryoPH.sln index ea5a2b9..f95709a 100644 --- a/EnotaryoPH/EnotaryoPH.sln +++ b/EnotaryoPH/EnotaryoPH.sln @@ -14,6 +14,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution ..\README.md = ..\README.md EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EnotaryoPH.DbMigration", "EnotaryoPH.DbMigration\EnotaryoPH.DbMigration.csproj", "{191EA7CD-B89A-4F4B-895A-790A20B20461}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -28,6 +30,10 @@ Global {7B06785D-1B94-472B-885C-3C2F8834438B}.Debug|Any CPU.Build.0 = Debug|Any CPU {7B06785D-1B94-472B-885C-3C2F8834438B}.Release|Any CPU.ActiveCfg = Release|Any CPU {7B06785D-1B94-472B-885C-3C2F8834438B}.Release|Any CPU.Build.0 = Release|Any CPU + {191EA7CD-B89A-4F4B-895A-790A20B20461}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {191EA7CD-B89A-4F4B-895A-790A20B20461}.Debug|Any CPU.Build.0 = Debug|Any CPU + {191EA7CD-B89A-4F4B-895A-790A20B20461}.Release|Any CPU.ActiveCfg = Release|Any CPU + {191EA7CD-B89A-4F4B-895A-790A20B20461}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From a21ecd796ced1cd79941d56918a235c51c2a5fe1 Mon Sep 17 00:00:00 2001 From: jojo aquino Date: Sun, 20 Apr 2025 09:00:10 +0100 Subject: [PATCH 02/14] add web config for dev --- EnotaryoPH/EnotaryoPH.Web/web.dev.config | 15 +++++++++++++++ EnotaryoPH/EnotaryoPH.Web/web.local.config | 15 +++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 EnotaryoPH/EnotaryoPH.Web/web.dev.config create mode 100644 EnotaryoPH/EnotaryoPH.Web/web.local.config diff --git a/EnotaryoPH/EnotaryoPH.Web/web.dev.config b/EnotaryoPH/EnotaryoPH.Web/web.dev.config new file mode 100644 index 0000000..314a024 --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.Web/web.dev.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/EnotaryoPH/EnotaryoPH.Web/web.local.config b/EnotaryoPH/EnotaryoPH.Web/web.local.config new file mode 100644 index 0000000..314a024 --- /dev/null +++ b/EnotaryoPH/EnotaryoPH.Web/web.local.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file From 10e67a001c3e4dcad20d2dd5e0bef415d94cc925 Mon Sep 17 00:00:00 2001 From: jojo aquino Date: Mon, 21 Apr 2025 06:51:13 +0100 Subject: [PATCH 03/14] missing ; --- EnotaryoPH/EnotaryoPH.DbMigration/Scripts/01_Schema.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/01_Schema.sql b/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/01_Schema.sql index 3ae833c..6ff778a 100644 --- a/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/01_Schema.sql +++ b/EnotaryoPH/EnotaryoPH.DbMigration/Scripts/01_Schema.sql @@ -712,4 +712,4 @@ CREATE OR REPLACE FUNCTION public.uuid_ns_x500() LANGUAGE c IMMUTABLE PARALLEL SAFE STRICT AS '$libdir/uuid-ossp', $function$uuid_ns_x500$function$ -; \ No newline at end of file +; From d945ef9527eef6d7b84b5d83c4a1ea0b98e177a5 Mon Sep 17 00:00:00 2001 From: jojo aquino Date: Mon, 21 Apr 2025 07:53:55 +0100 Subject: [PATCH 04/14] update make file --- make.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/make.ps1 b/make.ps1 index 66590bc..16a318f 100644 --- a/make.ps1 +++ b/make.ps1 @@ -4,11 +4,15 @@ param( $OutputDir ) + +Remove-Item -Path $OutputDir -Recurse -Force + +dotnet publish .\EnotaryoPH\EnotaryoPH.DbMigration\EnotaryoPH.DbMigration.csproj --nologo --output "$OutputDir\migration" + cd EnotaryoPH/EnotaryoPH.Web npm install --production -dotnet publish EnotaryoPH.Web.csproj --nologo --output $OutputDir - +dotnet publish EnotaryoPH.Web.csproj --nologo --output "$OutputDir\web" From 0a5a2b3674584966c23516aa5aa9fcb8423895da Mon Sep 17 00:00:00 2001 From: jojo aquino Date: Mon, 21 Apr 2025 07:59:30 +0100 Subject: [PATCH 05/14] azure pipeline --- azure-pipelines.yml | 128 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 101 insertions(+), 27 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 2947be6..1ce6220 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,64 +12,138 @@ variables: buildConfiguration: 'Release' pool: - vmImage: 'ubuntu-latest' # This default pool will be used for Linux builds + vmImage: 'ubuntu-latest' stages: - stage: Build jobs: - - job: LinuxBuild - displayName: 'Build on Linux' - pool: - vmImage: 'ubuntu-latest' + + - job: SetupEnvironment + displayName: "Setup Build Environment" steps: - - task: UseDotNet@2 - inputs: - packageType: 'sdk' - version: '9.0.x' + - task: PowerShell@2 + name: "diffStep" + inputs: + targetType: 'inline' + script: | + $diffResult = git diff --name-only HEAD~1 HEAD + $folderFound = $false + if ([string]::IsNullOrWhiteSpace($diffResult)) { + Write-Host "No diff results found." + Write-Host "##vso[task.setvariable variable=folderChanged;isOutput=true]$folderFound" + exit 0 # Exit with success code + } - - task: NodeTool@0 - inputs: - versionSource: 'spec' - versionSpec: '20.x' + $diffResultEncoded = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($diffResult)) + Write-Host "##vso[task.setvariable variable=diffResultEncoded]$diffResultEncoded" + + $foldersToCheck = @('EnotaryoPH/EnotaryoPH.DbMigration/Scripts') + foreach ($folder in $foldersToCheck) { + if ($diffResult -match $folder) { + $folderFound = $true + Write-Host "Found changes in $folder" + break + } + } + Write-Host "##vso[task.setvariable variable=folderChanged;isOutput=true]$folderFound" + displayName: 'Check Git Diff for Specific Folders' + + - task: UseDotNet@2 + inputs: + packageType: 'sdk' + version: '9.0.x' + + - task: NodeTool@0 + inputs: + versionSource: 'spec' + versionSpec: '20.x' + + - job: LinuxBuild + displayName: 'Build on Linux' + dependsOn: SetupEnvironment + variables: + folderChanged: $[ dependencies.SetupEnvironment.outputs['diffStep.folderChanged'] ] + pool: + vmImage: 'ubuntu-latest' + steps: - task: PowerShell@2 inputs: filePath: 'make.ps1' arguments: '-OutputDir $(Build.ArtifactStagingDirectory)-linux' + - task: ArchiveFiles@2 + inputs: + rootFolderOrFile: '$(Build.ArtifactStagingDirectory)-linux/web' + includeRootFolder: true + archiveType: 'zip' + archiveFile: '$(Build.ArtifactStagingDirectory)-linux/$(Build.BuildId)/web.zip' + replaceExistingArchive: true + - task: PublishBuildArtifacts@1 inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)-linux' - ArtifactName: 'drop-linux' + PathtoPublish: '$(Build.ArtifactStagingDirectory)-linux/$(Build.BuildId)/web.zip' + ArtifactName: 'drop-linux-web' publishLocation: 'Container' + - task: ArchiveFiles@2 + condition: eq(variables['folderChanged'], 'True') + inputs: + rootFolderOrFile: '$(Build.ArtifactStagingDirectory)-linux/migration' + includeRootFolder: true + archiveType: 'zip' + archiveFile: '$(Build.ArtifactStagingDirectory)-linux/$(Build.BuildId)/migration.zip' + replaceExistingArchive: true + + - task: PublishBuildArtifacts@1 + condition: eq(variables['folderChanged'], 'True') + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId)/migration.zip' + ArtifactName: 'drop-linux-migration' + publishLocation: 'Container' - job: WindowsBuild displayName: 'Build on Windows' + dependsOn: SetupEnvironment + variables: + folderChanged: $[ dependencies.SetupEnvironment.outputs['diffStep.folderChanged'] ] pool: vmImage: 'windows-latest' # Specify the Windows agent steps: - - task: UseDotNet@2 - inputs: - packageType: 'sdk' - version: '9.0.x' - - - task: NodeTool@0 - inputs: - versionSource: 'spec' - versionSpec: '20.x' - - task: PowerShell@2 inputs: filePath: 'make.ps1' arguments: '-OutputDir $(Build.ArtifactStagingDirectory)-windows' + - task: ArchiveFiles@2 + inputs: + rootFolderOrFile: '$(Build.ArtifactStagingDirectory)-windows/web' + includeRootFolder: true + archiveType: 'zip' + archiveFile: '$(Build.ArtifactStagingDirectory)-windows/$(Build.BuildId)/web.zip' + replaceExistingArchive: true - task: PublishBuildArtifacts@1 inputs: - PathtoPublish: '$(Build.ArtifactStagingDirectory)-windows' - ArtifactName: 'drop-windows' + PathtoPublish: '$(Build.ArtifactStagingDirectory)-windows/$(Build.BuildId)/web.zip' + ArtifactName: 'drop-windows-web' + publishLocation: 'Container' + + - task: ArchiveFiles@2 + condition: eq(variables['folderChanged'], 'True') + inputs: + rootFolderOrFile: '$(Build.ArtifactStagingDirectory)-windows/migration' + includeRootFolder: true + archiveType: 'zip' + archiveFile: '$(Build.ArtifactStagingDirectory)-windows/$(Build.BuildId)/migration.zip' + replaceExistingArchive: true + + - task: PublishBuildArtifacts@1 + condition: eq(variables['folderChanged'], 'True') + inputs: + PathtoPublish: '$(Build.ArtifactStagingDirectory)-windows/$(Build.BuildId)/migration.zip' + ArtifactName: 'drop-windows-migration' publishLocation: 'Container' From 440615cf9b078c94e4aebb0d0738ca3ef712974d Mon Sep 17 00:00:00 2001 From: jojo aquino Date: Mon, 21 Apr 2025 08:06:43 +0100 Subject: [PATCH 06/14] add SilentlyContinue --- make.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make.ps1 b/make.ps1 index 16a318f..2556928 100644 --- a/make.ps1 +++ b/make.ps1 @@ -5,7 +5,7 @@ param( ) -Remove-Item -Path $OutputDir -Recurse -Force +Remove-Item -Path $OutputDir -Recurse -Force -ErrorAction SilentlyContinue dotnet publish .\EnotaryoPH\EnotaryoPH.DbMigration\EnotaryoPH.DbMigration.csproj --nologo --output "$OutputDir\migration" From d87f906ec11663d3f109c2d4298a1a0013ecfcb2 Mon Sep 17 00:00:00 2001 From: jojo aquino Date: Mon, 21 Apr 2025 08:13:36 +0100 Subject: [PATCH 07/14] move UseDotNet back to each job --- azure-pipelines.yml | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 1ce6220..7cf9738 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -49,16 +49,6 @@ stages: Write-Host "##vso[task.setvariable variable=folderChanged;isOutput=true]$folderFound" displayName: 'Check Git Diff for Specific Folders' - - task: UseDotNet@2 - inputs: - packageType: 'sdk' - version: '9.0.x' - - - task: NodeTool@0 - inputs: - versionSource: 'spec' - versionSpec: '20.x' - - job: LinuxBuild displayName: 'Build on Linux' dependsOn: SetupEnvironment @@ -68,6 +58,16 @@ stages: vmImage: 'ubuntu-latest' steps: + - task: UseDotNet@2 + inputs: + packageType: 'sdk' + version: '9.0.x' + + - task: NodeTool@0 + inputs: + versionSource: 'spec' + versionSpec: '20.x' + - task: PowerShell@2 inputs: filePath: 'make.ps1' @@ -112,6 +112,16 @@ stages: vmImage: 'windows-latest' # Specify the Windows agent steps: + - task: UseDotNet@2 + inputs: + packageType: 'sdk' + version: '9.0.x' + + - task: NodeTool@0 + inputs: + versionSource: 'spec' + versionSpec: '20.x' + - task: PowerShell@2 inputs: filePath: 'make.ps1' From 86542f8f5ee7da1c3b1421311e24b25f66d16127 Mon Sep 17 00:00:00 2001 From: Jojo Aquino Date: Mon, 21 Apr 2025 07:18:04 +0000 Subject: [PATCH 08/14] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7cf9738..6173d43 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -59,12 +59,12 @@ stages: steps: - task: UseDotNet@2 - inputs: + inputs: packageType: 'sdk' version: '9.0.x' - task: NodeTool@0 - inputs: + inputs: versionSource: 'spec' versionSpec: '20.x' @@ -113,12 +113,12 @@ stages: steps: - task: UseDotNet@2 - inputs: + inputs: packageType: 'sdk' version: '9.0.x' - task: NodeTool@0 - inputs: + inputs: versionSource: 'spec' versionSpec: '20.x' From 2b4f7371021104d7c14a11399a537843f281f121 Mon Sep 17 00:00:00 2001 From: Jojo Aquino Date: Mon, 21 Apr 2025 07:30:52 +0000 Subject: [PATCH 09/14] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6173d43..f97960d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,7 +27,8 @@ stages: inputs: targetType: 'inline' script: | - $diffResult = git diff --name-only HEAD~1 HEAD + git fetch origin $(Build.SourceBranchName) $(Build.Repository.DefaultBranch) + $diffResult = git diff --name-only origin/$(Build.Repository.DefaultBranch)...HEAD $folderFound = $false if ([string]::IsNullOrWhiteSpace($diffResult)) { Write-Host "No diff results found." From 2756fa2fa627ab5e45803afe65fc3d43e5c43771 Mon Sep 17 00:00:00 2001 From: Jojo Aquino Date: Mon, 21 Apr 2025 07:33:43 +0000 Subject: [PATCH 10/14] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f97960d..0d9c762 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -107,6 +107,7 @@ stages: - job: WindowsBuild displayName: 'Build on Windows' dependsOn: SetupEnvironment + condition: ne(variables['Build.Reason'], 'PullRequest') variables: folderChanged: $[ dependencies.SetupEnvironment.outputs['diffStep.folderChanged'] ] pool: From b8c2508b2c90e3fd0f95add7f25d3ef6171d2fc5 Mon Sep 17 00:00:00 2001 From: Jojo Aquino Date: Mon, 21 Apr 2025 07:44:43 +0000 Subject: [PATCH 11/14] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0d9c762..727ed95 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,7 +27,7 @@ stages: inputs: targetType: 'inline' script: | - git fetch origin $(Build.SourceBranchName) $(Build.Repository.DefaultBranch) + git fetch origin "$(Build.SourceBranchName)" "$(Build.Repository.DefaultBranch)" $diffResult = git diff --name-only origin/$(Build.Repository.DefaultBranch)...HEAD $folderFound = $false if ([string]::IsNullOrWhiteSpace($diffResult)) { From e808c7f70a52068e303ac454b6f00f798dc564fd Mon Sep 17 00:00:00 2001 From: Jojo Aquino Date: Mon, 21 Apr 2025 07:59:18 +0000 Subject: [PATCH 12/14] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 727ed95..879eff4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,7 +27,13 @@ stages: inputs: targetType: 'inline' script: | - git fetch origin "$(Build.SourceBranchName)" "$(Build.Repository.DefaultBranch)" + Write-Host "##[section]All Environment Variables:" + Get-ChildItem env: | Format-Table -AutoSize + + Write-Host "##[section]Specific Variable Example:" + Write-Host "BUILD_SOURCEBRANCH = $env:BUILD_SOURCEBRANCH" + Write-Host "BUILD_REPOSITORY_NAME = $env:BUILD_REPOSITORY_NAME" + git fetch origin "$(Build.SourceBranchName)" "$env:BUILD_REPOSITORY_DEFAULTBRANCH" $diffResult = git diff --name-only origin/$(Build.Repository.DefaultBranch)...HEAD $folderFound = $false if ([string]::IsNullOrWhiteSpace($diffResult)) { From db9a8fa1a31b68779c7b2cfaa81eaacd99a2588a Mon Sep 17 00:00:00 2001 From: Jojo Aquino Date: Mon, 21 Apr 2025 08:11:22 +0000 Subject: [PATCH 13/14] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 879eff4..6eb2b06 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -33,7 +33,7 @@ stages: Write-Host "##[section]Specific Variable Example:" Write-Host "BUILD_SOURCEBRANCH = $env:BUILD_SOURCEBRANCH" Write-Host "BUILD_REPOSITORY_NAME = $env:BUILD_REPOSITORY_NAME" - git fetch origin "$(Build.SourceBranchName)" "$env:BUILD_REPOSITORY_DEFAULTBRANCH" + git fetch origin "$(Build.SourceBranchName)" main $diffResult = git diff --name-only origin/$(Build.Repository.DefaultBranch)...HEAD $folderFound = $false if ([string]::IsNullOrWhiteSpace($diffResult)) { From 102185864a22b466d75c75d43840d69ff8c8702b Mon Sep 17 00:00:00 2001 From: Jojo Aquino Date: Mon, 21 Apr 2025 08:12:07 +0000 Subject: [PATCH 14/14] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 6eb2b06..991757b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -34,7 +34,7 @@ stages: Write-Host "BUILD_SOURCEBRANCH = $env:BUILD_SOURCEBRANCH" Write-Host "BUILD_REPOSITORY_NAME = $env:BUILD_REPOSITORY_NAME" git fetch origin "$(Build.SourceBranchName)" main - $diffResult = git diff --name-only origin/$(Build.Repository.DefaultBranch)...HEAD + $diffResult = git diff --name-only origin/main...HEAD $folderFound = $false if ([string]::IsNullOrWhiteSpace($diffResult)) { Write-Host "No diff results found."