Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@
"jsonwebtoken": "^9.0.3",
"multer": "^1.4.5-lts.2",
"node-cron": "^4.2.1",
"node-vault": "^0.10.2",
"nodemailer": "^6.10.1",
"node-vault": "^0.12.0",
"nodemailer": "^9.0.1",
"opossum": "^9.0.0",
"pdfkit": "^0.18.0",
"prom-client": "^15.1.0",
"rate-limit-redis": "^4.0.0",
"swagger-jsdoc": "^6.2.8",
"swagger-ui-express": "^5.0.1",
"uuid": "^9.0.0",
"vite": "6.4.1",
"vite": "^6.4.3",
"winston": "^3.19.0",
"zod": "^4.3.6"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
-- CreateTable
CREATE TABLE "ContractEvent" (
"id" TEXT NOT NULL PRIMARY KEY,
"contractId" TEXT NOT NULL,
"ledger" INTEGER NOT NULL,
"ledgerClosedAt" DATETIME NOT NULL,
"txHash" TEXT NOT NULL,
"contractEventId" TEXT NOT NULL,
"topics" TEXT NOT NULL,
"value" TEXT NOT NULL,
"type" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP
);

-- CreateTable
CREATE TABLE "MultisigTransaction" (
"id" TEXT NOT NULL PRIMARY KEY,
"envelopeXdr" TEXT NOT NULL,
"hash" TEXT NOT NULL,
"creatorPublicKey" TEXT NOT NULL,
"requiredSigners" JSONB NOT NULL,
"threshold" INTEGER NOT NULL,
"currentSignatures" INTEGER NOT NULL DEFAULT 0,
"status" TEXT NOT NULL DEFAULT 'PENDING',
"memo" TEXT,
"expiresAt" DATETIME,
"submittedAt" DATETIME,
"stellarTxId" TEXT,
"metadata" JSONB,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" DATETIME NOT NULL
);

-- CreateTable
CREATE TABLE "MultisigSignature" (
"id" TEXT NOT NULL PRIMARY KEY,
"multisigTransactionId" TEXT NOT NULL,
"signerPublicKey" TEXT NOT NULL,
"signature" TEXT NOT NULL,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "MultisigSignature_multisigTransactionId_fkey" FOREIGN KEY ("multisigTransactionId") REFERENCES "MultisigTransaction" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);

-- CreateTable
CREATE TABLE "MultisigNotification" (
"id" TEXT NOT NULL PRIMARY KEY,
"multisigTransactionId" TEXT NOT NULL,
"recipientPublicKey" TEXT NOT NULL,
"type" TEXT NOT NULL,
"message" TEXT NOT NULL,
"readAt" DATETIME,
"sentAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
"createdAt" DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "MultisigNotification_multisigTransactionId_fkey" FOREIGN KEY ("multisigTransactionId") REFERENCES "MultisigTransaction" ("id") ON DELETE CASCADE ON UPDATE CASCADE
);

-- CreateTable
CREATE TABLE "AssetValidationResult" (
"assetCode" TEXT NOT NULL,
"issuerPublicKey" TEXT NOT NULL,
"homeDomain" TEXT,
"complianceStatus" TEXT NOT NULL,
"messages" TEXT NOT NULL,
"rawToml" TEXT,
"lastCrawledAt" DATETIME NOT NULL,

PRIMARY KEY ("assetCode", "issuerPublicKey")
);

-- CreateTable
CREATE TABLE "CrawlJobRecord" (
"id" TEXT NOT NULL PRIMARY KEY,
"startedAt" DATETIME NOT NULL,
"completedAt" DATETIME,
"totalAssets" INTEGER NOT NULL,
"compliantCount" INTEGER NOT NULL,
"nonCompliantCount" INTEGER NOT NULL,
"suspiciousCount" INTEGER NOT NULL
);

-- CreateIndex
CREATE UNIQUE INDEX "ContractEvent_contractEventId_key" ON "ContractEvent"("contractEventId");

-- CreateIndex
CREATE INDEX "ContractEvent_contractId_idx" ON "ContractEvent"("contractId");

-- CreateIndex
CREATE INDEX "ContractEvent_txHash_idx" ON "ContractEvent"("txHash");

-- CreateIndex
CREATE INDEX "ContractEvent_ledger_idx" ON "ContractEvent"("ledger");

-- CreateIndex
CREATE UNIQUE INDEX "MultisigTransaction_hash_key" ON "MultisigTransaction"("hash");

-- CreateIndex
CREATE UNIQUE INDEX "MultisigTransaction_stellarTxId_key" ON "MultisigTransaction"("stellarTxId");

-- CreateIndex
CREATE UNIQUE INDEX "MultisigSignature_multisigTransactionId_signerPublicKey_key" ON "MultisigSignature"("multisigTransactionId", "signerPublicKey");

-- CreateIndex
CREATE INDEX "MultisigNotification_recipientPublicKey_readAt_idx" ON "MultisigNotification"("recipientPublicKey", "readAt");

-- CreateIndex
CREATE UNIQUE INDEX "AssetValidationResult_assetCode_issuerPublicKey_key" ON "AssetValidationResult"("assetCode", "issuerPublicKey");
2 changes: 1 addition & 1 deletion backend/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ generator client {
}

datasource db {
provider = "postgresql"
provider = "sqlite"
url = env("DATABASE_URL")
}

Expand Down
18 changes: 12 additions & 6 deletions backend/scripts/verify-migrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import { execSync } from 'child_process';
import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';

interface MigrationCheckResult {
success: boolean;
Expand All @@ -33,12 +32,15 @@ interface MigrationCheckResult {

class MigrationVerifier {
private tempDbPath: string;
private tempDbUrl: string;
private prismaBinary: string;
private schemaPath: string;
private migrationsPath: string;

constructor() {
this.tempDbPath = path.join(os.tmpdir(), `prisma-verify-${Date.now()}.db`);
const tempDbName = `prisma-verify-${Date.now()}.db`;
this.tempDbPath = path.join(__dirname, '..', tempDbName);
this.tempDbUrl = `file:./${tempDbName}`;
this.prismaBinary = 'npx prisma';
this.schemaPath = path.join(__dirname, '../prisma/schema.prisma');
this.migrationsPath = path.join(__dirname, '../prisma/migrations');
Expand All @@ -55,7 +57,9 @@ class MigrationVerifier {
...options,
});
} catch (error: any) {
throw new Error(`Command failed: ${command}\n${error.message}`);
const stdout = error.stdout ? `\nstdout:\n${error.stdout}` : '';
const stderr = error.stderr ? `\nstderr:\n${error.stderr}` : '';
throw new Error(`Command failed: ${command}\n${error.message}${stdout}${stderr}`);
}
}

Expand All @@ -70,7 +74,9 @@ class MigrationVerifier {
...options,
});
} catch (error: any) {
throw new Error(`Command failed: ${command}\n${error.message}`);
const stdout = error.stdout ? `\nstdout:\n${error.stdout}` : '';
const stderr = error.stderr ? `\nstderr:\n${error.stderr}` : '';
throw new Error(`Command failed: ${command}\n${error.message}${stdout}${stderr}`);
}
}

Expand Down Expand Up @@ -114,8 +120,8 @@ class MigrationVerifier {
DATABASE_URL: process.env.DATABASE_URL || `file:${this.tempDbPath}`,
};

// Reset and apply migrations
this.runSilent(`${this.prismaBinary} migrate reset --force`, {
// Apply committed migrations to the temporary database.
this.runSilent(`${this.prismaBinary} migrate deploy`, {
env,
cwd: path.join(__dirname, '..'),
});
Expand Down
8 changes: 8 additions & 0 deletions backend/src/lib/db.service.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import prisma from './db.service';

describe('Database Service', () => {
it('exports a Prisma client', () => {
expect(prisma).toBeDefined();
expect(prisma.$connect).toEqual(expect.any(Function));
});
});
2 changes: 1 addition & 1 deletion dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"storybook": "^8.6.12",
"tailwindcss": "^3.4.19",
"typescript": "^5.5.3",
"vite": "^6.4.1",
"vite": "^6.4.3",
"vitest": "^4.1.7"
}
}
Loading
Loading