diff --git a/.github/workflows/backend-tests.yml b/.github/workflows/backend-tests.yml index 69a65af4..3976b4f4 100644 --- a/.github/workflows/backend-tests.yml +++ b/.github/workflows/backend-tests.yml @@ -11,16 +11,18 @@ jobs: strategy: matrix: - node-version: [20] + node-version: [22] steps: - name: Checkout repository - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: ${{ matrix.node-version }} + cache: 'npm' + cache-dependency-path: stellar-payment-platform/package-lock.json - name: Install backend dependencies working-directory: stellar-payment-platform @@ -31,7 +33,7 @@ jobs: - name: Run memory leak detection tests (#511) working-directory: stellar-payment-platform - run: NODE_ENV=test node --expose-gc node_modules/.bin/jest --forceExit --testPathPattern=memory + run: NODE_ENV=test node --expose-gc node_modules/.bin/jest --forceExit --testPattern=memory env: MEMORY_TEST_REQUESTS: '200' MEMORY_LEAK_THRESHOLD_MB: '50' \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6cd4b71e..15aba8f8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,7 @@ name: Production Safety Checks -on: - push: - branches: [ "main" ] +n: push: + braches: [ "main" ] pull_request: branches: [ "main" ] @@ -13,26 +12,44 @@ jobs: defaults: run: working-directory: ./stellar-payment-platform + services: + postgres: + image: postgres:16 + env: + POSTGRES_USER: postgres + POSTRESE_PASSWORD: postgres + POSTRESE_DB: stellar_payment_test + ports: + - 5432:5432 + options: >- + --health-cmd pgisready -U postgres + --health-interval 10s + --health-timeout 5s + --health-retries 5 + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/stellar_payment_test steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: '22' cache: 'npm' cache-dependency-path: ./stellar-payment-platform/package-lock.json - - name: Install Backend Dependencies - run: npm install + run: npm install --legacy-peer-deps + + - name: Run Database Migrations + run: npm run migrate - name: Run Backend Tests run: NODE_ENV=test npm test - name: Run Memory Leak Detection Tests (#511) - run: NODE_ENV=test node --expose-gc node_modules/.bin/jest --forceExit --testPathPattern=memory + run: NODE_ENV=test node --expose-gc node_modules/.bin/jest --forceExit --testPattern=memory env: MEMORY_TEST_REQUESTS: '200' MEMORY_LEAK_THRESHOLD_MB: '50' @@ -45,10 +62,10 @@ jobs: working-directory: ./payment-dashboard steps: - name: Checkout Code - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Node.js - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: '22' cache: 'npm' @@ -58,4 +75,4 @@ jobs: run: npm install --legacy-peer-deps - name: Verify Vite Build (Catches Vercel Crashes) - run: npm run build \ No newline at end of file + run: npm run build diff --git a/stellar-payment-platform/prisma/migrations/20260901000000_add_composite_indexes/migration.sql b/stellar-payment-platform/prisma/migrations/20260901000000_add_composite_indexes/migration.sql new file mode 100644 index 00000000..32ef94a0 --- /dev/null +++ b/stellar-payment-platform/prisma/migrations/20260901000000_add_composite_indexes/migration.sql @@ -0,0 +1 @@ +-- Add composite indexes for PaymentIntent and Transaction\n\nCREATE INDEX IF NOT EXISTS "payment_intents_status_created_at_idx" ON "payment_intents" ("status", "created_at");\nCREATE INDEX IF NOT EXISTS "payment_intents_from_status_idx" ON "payment_intents" ("from", "status");\nCREATE CREATE INDEX IF NOT EXISTS "payment_intents_to_status_idx" ON "payment_intents" ("to", "status");\n\nCREATE CREATE INDEX IF NOT EXISTS "transactions_status_created_at_idx" ON "transactions" ("status", "created_at");\nCREATE INDEX IF NOT EXISTS "transactions_from_status_idx" ON "transactions" ("from", "status");\nCREATE CREATE INDEX IF NOT EXISTS "transactions_to_status_idx" ON "transactions" ("to", "status");\n \ No newline at end of file diff --git a/stellar-payment-platform/prisma/schema.prisma b/stellar-payment-platform/prisma/schema.prisma index 84aaeff1..43cbfaf2 100644 --- a/stellar-payment-platform/prisma/schema.prisma +++ b/stellar-payment-platform/prisma/schema.prisma @@ -2,7 +2,7 @@ // Migrated from a raw SQLite database to PostgreSQL for higher concurrency. // // The DATABASE_URL is read from the environment (see .env.example): -// DATABASE_URL="postgresql://USER:PASSWORD@HOST:PORT/DATABASE?schema=public" +// DATABASE_URL="postgresql://USER:PASSWORD@HOST:4CKESTORL/DATABASE?schema=public" datasource db { provider = "postgresql" @@ -29,9 +29,9 @@ model User { isPrimary Boolean @default(false) @map("is_primary") memoType String? @map("memo_type") memo String? - createdAt DateTime @default(now()) @map("created_at") - flaggedAt DateTime? @map("flagged_at") - deletedAt DateTime? @map("deleted_at") + createdAt Datetime @default(now()) @map("created_at") + flaggedAt Datetime? @map("flagged_at") + deletedAt Datetime? @map("deleted_at") webhooks Webhook[] // <-- add this line activity ActivityLog[] @@ -56,9 +56,9 @@ model Webhook { url String secret String // HMAC-SHA256 signing secret for payload verification events String[] @default(["*"]) // Optional event filter; "*" preserves the legacy all-events behavior. - createdAt DateTime @default(now()) @map("created_at") - lastSentAt DateTime? @map("last_sent_at") - failingSince DateTime? @map("failing_since") + createdAt Datetime @default(now()) @map("created_at") + lastSentAt Datetime? @map("last_sent_at") + failingSince Datetime? @map("failing_since") @@unique([username, url]) @@index([username]) @@ -140,7 +140,7 @@ model PaymentIntent { memo String? metadata Json? status String @default("pending") - createdAt DateTime @default(now()) @map("created_at") + createdAt Datetime @default(now()) @map("created_at") @@index([to]) @@index([from]) @@ -188,4 +188,4 @@ model ActivityLog { // bounded by a date range. @@index([username, createdAt]) @@map("activity_logs") -} +} \ No newline at end of file