diff --git a/apps/backend/.env.example b/apps/backend/.env.example index 8fa21294..60449b4f 100644 --- a/apps/backend/.env.example +++ b/apps/backend/.env.example @@ -1,4 +1,8 @@ # Database Configuration +# When DATABASE_URL is set, PostgreSQL will be used automatically. +# Otherwise the backend falls back to local SQLite using DATABASE_PATH. +DATABASE_URL=postgresql://vaultix_user:vaultix_password@localhost:5432/vaultix_db +DATABASE_SSL=false DATABASE_PATH=./data/vaultix.db # JWT Configuration diff --git a/apps/backend/package-lock.json b/apps/backend/package-lock.json index d62d1d7c..2ce072d3 100644 --- a/apps/backend/package-lock.json +++ b/apps/backend/package-lock.json @@ -33,6 +33,7 @@ "nodemailer": "^8.0.3", "passport": "^0.7.0", "passport-jwt": "^4.0.1", + "pg": "^8.11.0", "reflect-metadata": "^0.2.2", "rxjs": "^7.8.1", "socket.io": "^4.8.3", @@ -753,7 +754,7 @@ "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, + "devOptional": true, "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "0.3.9" @@ -766,7 +767,7 @@ "version": "0.3.9", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, + "devOptional": true, "license": "MIT", "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", @@ -1915,7 +1916,7 @@ "version": "3.1.2", "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", - "dev": true, + "devOptional": true, "license": "MIT", "engines": { "node": ">=6.0.0" @@ -1936,7 +1937,7 @@ "version": "1.5.5", "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/@jridgewell/trace-mapping": { @@ -2732,28 +2733,28 @@ "version": "1.0.12", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.12.tgz", "integrity": "sha512-UCYBaeFvM11aU2y3YPZ//O5Rhj+xKyzy7mvcIoAjASbigy8mHMryP5cK7dgjlz2hWxh1g5pLw084E0a/wlUSFQ==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/@tsconfig/node12": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node12/-/node12-1.0.11.tgz", "integrity": "sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/@tsconfig/node14": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/@tsconfig/node14/-/node14-1.0.3.tgz", "integrity": "sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/@tsconfig/node16": { "version": "1.0.4", "resolved": "https://registry.npmjs.org/@tsconfig/node16/-/node16-1.0.4.tgz", "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/@types/babel__core": { @@ -3584,7 +3585,7 @@ "version": "8.15.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.15.0.tgz", "integrity": "sha512-NZyJarBfL7nWwIq+FDL6Zp/yHEhePMNnnJ0y3qfieCrmNvYct8uvtiV41UvlSe6apAfk0fY1FbWx+NwfmpvtTg==", - "dev": true, + "devOptional": true, "license": "MIT", "bin": { "acorn": "bin/acorn" @@ -3620,7 +3621,7 @@ "version": "8.3.4", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.4.tgz", "integrity": "sha512-ueEepnujpqee2o5aIYnvHU6C0A42MNdsIDeqy5BydrkuC5R1ZuUFnm27EeFJGoEHJQgn3uleRvmTXaJgfXbt4g==", - "dev": true, + "devOptional": true, "license": "MIT", "dependencies": { "acorn": "^8.11.0" @@ -3865,7 +3866,7 @@ "version": "4.1.3", "resolved": "https://registry.npmjs.org/arg/-/arg-4.1.3.tgz", "integrity": "sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/argparse": { @@ -5004,7 +5005,7 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/create-require/-/create-require-1.1.1.tgz", "integrity": "sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/cron": { @@ -5205,7 +5206,7 @@ "version": "4.0.4", "resolved": "https://registry.npmjs.org/diff/-/diff-4.0.4.tgz", "integrity": "sha512-X07nttJQkwkfKfvTPG/KSnE2OMdcUCao6+eXF3wmnIQRn2aPAHH3VxDbDOdegkd6JbPsXqShpvEOHfAT+nCNwQ==", - "dev": true, + "devOptional": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.3.1" @@ -8192,7 +8193,7 @@ "version": "1.3.6", "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", - "dev": true, + "devOptional": true, "license": "ISC" }, "node_modules/make-fetch-happen": { @@ -9292,6 +9293,95 @@ "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", "integrity": "sha512-KG8UEiEVkR3wGEb4m5yZkVCzigAD+cVEJck2CzYZO37ZGJfctvVptVO192MwrtPhzONn6go8ylnOdMhKqi4nfg==" }, + "node_modules/pg": { + "version": "8.21.0", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.21.0.tgz", + "integrity": "sha512-AUP1EYJuHraQGsVoCQVIcM7TEJVGtDzxWtGFZd8rds9d+CCXlU5Js1rYgfLNvxy9iJrpHjGrRjoi/3BT9fRyiA==", + "license": "MIT", + "dependencies": { + "pg-connection-string": "^2.13.0", + "pg-pool": "^3.14.0", + "pg-protocol": "^1.14.0", + "pg-types": "2.2.0", + "pgpass": "1.0.5" + }, + "engines": { + "node": ">= 16.0.0" + }, + "optionalDependencies": { + "pg-cloudflare": "^1.4.0" + }, + "peerDependencies": { + "pg-native": ">=3.0.1" + }, + "peerDependenciesMeta": { + "pg-native": { + "optional": true + } + } + }, + "node_modules/pg-cloudflare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/pg-cloudflare/-/pg-cloudflare-1.4.0.tgz", + "integrity": "sha512-Vo7z/6rrQYxpNRylp4Tlob2elzbh+N/MOQbxFVWCxS7oEx6jF53GTJFxK2WWpKuBRkmiin4Mt+xofFDjx09R0A==", + "license": "MIT", + "optional": true + }, + "node_modules/pg-connection-string": { + "version": "2.13.0", + "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-2.13.0.tgz", + "integrity": "sha512-EMnU9E2fSULdsbErBbMaXJvFeD9B4+nPcM3f+4lsiCR0BHLPrLVjv3DbyM2hgQQviKJaTWIRRTjKjWlHg3p2ig==", + "license": "MIT" + }, + "node_modules/pg-int8": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/pg-int8/-/pg-int8-1.0.1.tgz", + "integrity": "sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==", + "license": "ISC", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/pg-pool": { + "version": "3.14.0", + "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.14.0.tgz", + "integrity": "sha512-gKtPkFdQPU3DksooVLi9LsjZxrsBUZIpa+7aVx+LV5pNh0KzP4Zleud2po+ConrxbuXGBJ6Hfer6hdgpIBpBaw==", + "license": "MIT", + "peerDependencies": { + "pg": ">=8.0" + } + }, + "node_modules/pg-protocol": { + "version": "1.14.0", + "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.14.0.tgz", + "integrity": "sha512-n5taZ1kO3s9ngDTVxsEznOqCyToTgz0FLuPq0B33COy5pPpuWJpY3/2oRBVETuOgzdqRXfWpM9HIhp2LBBT1BA==", + "license": "MIT" + }, + "node_modules/pg-types": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", + "integrity": "sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==", + "license": "MIT", + "dependencies": { + "pg-int8": "1.0.1", + "postgres-array": "~2.0.0", + "postgres-bytea": "~1.0.0", + "postgres-date": "~1.0.4", + "postgres-interval": "^1.1.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/pgpass": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/pgpass/-/pgpass-1.0.5.tgz", + "integrity": "sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==", + "license": "MIT", + "dependencies": { + "split2": "^4.1.0" + } + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -9410,6 +9500,45 @@ "node": ">= 0.4" } }, + "node_modules/postgres-array": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-2.0.0.tgz", + "integrity": "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==", + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/postgres-bytea": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-1.0.1.tgz", + "integrity": "sha512-5+5HqXnsZPE65IJZSMkZtURARZelel2oXUEO8rH83VS/hxH5vv1uHquPg5wZs8yMAfdv971IU+kcPUczi7NVBQ==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-date": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-1.0.7.tgz", + "integrity": "sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==", + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/postgres-interval": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-1.2.0.tgz", + "integrity": "sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==", + "license": "MIT", + "dependencies": { + "xtend": "^4.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/prebuild-install": { "version": "7.1.3", "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz", @@ -10394,6 +10523,15 @@ "node": ">=0.10.0" } }, + "node_modules/split2": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/split2/-/split2-4.2.0.tgz", + "integrity": "sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==", + "license": "ISC", + "engines": { + "node": ">= 10.x" + } + }, "node_modules/sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", @@ -11289,7 +11427,7 @@ "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", "integrity": "sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==", - "dev": true, + "devOptional": true, "license": "MIT", "dependencies": { "@cspotcode/source-map-support": "^0.8.0", @@ -11672,7 +11810,7 @@ "version": "5.9.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", - "dev": true, + "devOptional": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -11868,7 +12006,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz", "integrity": "sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==", - "dev": true, + "devOptional": true, "license": "MIT" }, "node_modules/v8-to-istanbul": { @@ -12329,7 +12467,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/yn/-/yn-3.1.1.tgz", "integrity": "sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==", - "dev": true, + "devOptional": true, "license": "MIT", "engines": { "node": ">=6" diff --git a/apps/backend/package.json b/apps/backend/package.json index 546b9961..cf9aaabc 100644 --- a/apps/backend/package.json +++ b/apps/backend/package.json @@ -54,6 +54,7 @@ "rxjs": "^7.8.1", "socket.io": "^4.8.3", "sqlite3": "^5.1.7", + "pg": "^8.11.0", "stellar-sdk": "^13.3.0", "swagger-ui-express": "^5.0.1", "typeorm": "^0.3.28" diff --git a/apps/backend/src/app.controller.ts b/apps/backend/src/app.controller.ts index cce879ee..9d4c4f1c 100644 --- a/apps/backend/src/app.controller.ts +++ b/apps/backend/src/app.controller.ts @@ -1,12 +1,48 @@ import { Controller, Get } from '@nestjs/common'; +import { InjectDataSource } from '@nestjs/typeorm'; +import { DataSource } from 'typeorm'; import { AppService } from './app.service'; @Controller() export class AppController { - constructor(private readonly appService: AppService) {} + constructor( + private readonly appService: AppService, + @InjectDataSource() + private readonly dataSource: DataSource, + ) {} @Get() getHello(): string { return this.appService.getHello(); } + + @Get('health/database') + async getDatabaseHealth() { + const dbType = this.dataSource.options.type; + const isConnected = this.dataSource.isInitialized; + let migrationCount = 0; + let migrationStatus = 'unknown'; + + try { + await this.dataSource.query('SELECT 1'); + const result = await this.dataSource.query( + 'SELECT COUNT(*) as count FROM "migrations"', + ); + const countValue = Array.isArray(result) ? result[0]?.count : undefined; + migrationCount = typeof countValue === 'string' ? Number(countValue) : Number(countValue || 0); + migrationStatus = Number.isFinite(migrationCount) ? 'ok' : 'unknown'; + } catch (error) { + migrationStatus = 'unavailable'; + } + + return { + status: isConnected ? 'ok' : 'down', + database: { + type: dbType, + connected: isConnected, + migrationStatus, + migrationsExecuted: migrationCount, + }, + }; + } } diff --git a/apps/backend/src/app.module.ts b/apps/backend/src/app.module.ts index 6173db80..9f8d8116 100644 --- a/apps/backend/src/app.module.ts +++ b/apps/backend/src/app.module.ts @@ -43,32 +43,47 @@ import ipfsConfig from './config/ipfs.config'; ScheduleModule.forRoot(), TypeOrmModule.forRootAsync({ imports: [ConfigModule], - useFactory: (configService: ConfigService) => ({ - type: 'sqlite', - database: configService.get( + useFactory: (configService: ConfigService) => { + const databaseUrl = configService.get('DATABASE_URL'); + const databasePath = configService.get( 'DATABASE_PATH', './data/vaultix.db', - ), - entities: [ - User, - RefreshToken, - Escrow, - Party, - Condition, - EscrowEvent, - Dispute, - Notification, - NotificationPreference, - ApiKey, - AdminAuditLog, - Webhook, - StellarEvent, - AllowedAsset, - ], - synchronize: process.env.NODE_ENV === 'test', - migrations: [__dirname + '/migrations/*.ts'], - migrationsRun: process.env.NODE_ENV !== 'test', - }), + ); + const usePostgres = Boolean(databaseUrl); + const sslEnabled = configService.get('DATABASE_SSL') === 'true'; + + return { + type: usePostgres ? 'postgres' : 'better-sqlite3', + url: databaseUrl, + database: databasePath, + ssl: usePostgres ? (sslEnabled ? { rejectUnauthorized: false } : false) : false, + extra: usePostgres + ? { + min: 2, + max: 10, + } + : undefined, + entities: [ + User, + RefreshToken, + Escrow, + Party, + Condition, + EscrowEvent, + Dispute, + Notification, + NotificationPreference, + ApiKey, + AdminAuditLog, + Webhook, + StellarEvent, + AllowedAsset, + ], + synchronize: process.env.NODE_ENV === 'test', + migrations: [__dirname + '/migrations/*.ts'], + migrationsRun: process.env.NODE_ENV !== 'test', + }; + }, inject: [ConfigService], }), AuthModule, diff --git a/apps/backend/src/data-source.ts b/apps/backend/src/data-source.ts index 35987315..c295df11 100644 --- a/apps/backend/src/data-source.ts +++ b/apps/backend/src/data-source.ts @@ -17,9 +17,12 @@ import { AllowedAsset } from './modules/assets/entities/allowed-asset.entity'; config(); // Load .env file -export default new DataSource({ - type: 'sqlite', - database: process.env.DATABASE_PATH || './data/vaultix.db', +const databaseUrl = process.env.DATABASE_URL; +const sqlitePath = process.env.DATABASE_PATH || './data/vaultix.db'; +const usePostgres = Boolean(databaseUrl); +const sslEnabled = process.env.DATABASE_SSL === 'true'; + +const commonOptions = { entities: [ User, RefreshToken, @@ -38,4 +41,31 @@ export default new DataSource({ ], migrations: ['./src/migrations/*.ts'], synchronize: false, -}); +}; + +const postgresOptions = { + type: 'postgres' as const, + url: databaseUrl, + ssl: sslEnabled ? { rejectUnauthorized: false } : false, + extra: { + min: 2, + max: 10, + }, +}; + +const sqliteOptions = { + type: 'better-sqlite3' as const, + database: sqlitePath, +}; + +export default new DataSource( + usePostgres + ? { + ...commonOptions, + ...postgresOptions, + } + : { + ...commonOptions, + ...sqliteOptions, + }, +); diff --git a/apps/backend/src/migrations/1774364374006-InitialMigration.ts b/apps/backend/src/migrations/1774364374006-InitialMigration.ts index 778e6c36..84807efd 100644 --- a/apps/backend/src/migrations/1774364374006-InitialMigration.ts +++ b/apps/backend/src/migrations/1774364374006-InitialMigration.ts @@ -5,7 +5,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.query( - `CREATE TABLE "temporary_users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, + `CREATE TABLE "temporary_users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, ); await queryRunner.query( `INSERT INTO "temporary_users"("id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role") SELECT "id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role" FROM "users"`, @@ -13,25 +13,25 @@ export class InitialMigration1774364374006 implements MigrationInterface { await queryRunner.query(`DROP TABLE "users"`); await queryRunner.query(`ALTER TABLE "temporary_users" RENAME TO "users"`); await queryRunner.query( - `CREATE TABLE "disputes" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "filedByUserId" varchar NOT NULL, "reason" text NOT NULL, "evidence" text, "status" varchar NOT NULL DEFAULT ('open'), "resolvedByUserId" varchar, "resolutionNotes" text, "sellerPercent" decimal(5,2), "buyerPercent" decimal(5,2), "outcome" varchar, "resolvedAt" datetime, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "REL_05cc0a36ac22b4dc8a82211d2e" UNIQUE ("escrowId"))`, + `CREATE TABLE "disputes" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "filedByUserId" varchar NOT NULL, "reason" text NOT NULL, "evidence" text, "status" varchar NOT NULL DEFAULT ('open'), "resolvedByUserId" varchar, "resolutionNotes" text, "sellerPercent" decimal(5,2), "buyerPercent" decimal(5,2), "outcome" varchar, "resolvedAt" timestamp, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "REL_05cc0a36ac22b4dc8a82211d2e" UNIQUE ("escrowId"))`, ); await queryRunner.query( - `CREATE TABLE "notification" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "eventType" varchar CHECK( "eventType" IN ('ESCROW_CREATED','ESCROW_FUNDED','MILESTONE_RELEASED','ESCROW_COMPLETED','ESCROW_CANCELLED','DISPUTE_RAISED','DISPUTE_RESOLVED','ESCROW_EXPIRED') ) NOT NULL, "payload" text NOT NULL, "status" varchar CHECK( "status" IN ('pending','sent','failed') ) NOT NULL DEFAULT ('pending'), "retryCount" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`, + `CREATE TABLE "notification" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "eventType" varchar CHECK( "eventType" IN ('ESCROW_CREATED','ESCROW_FUNDED','MILESTONE_RELEASED','ESCROW_COMPLETED','ESCROW_CANCELLED','DISPUTE_RAISED','DISPUTE_RESOLVED','ESCROW_EXPIRED') ) NOT NULL, "payload" text NOT NULL, "status" varchar CHECK( "status" IN ('pending','sent','failed') ) NOT NULL DEFAULT ('pending'), "retryCount" integer NOT NULL DEFAULT (0), "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)`, ); await queryRunner.query( - `CREATE TABLE "notification_preference" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "channel" varchar CHECK( "channel" IN ('email','webhook') ) NOT NULL, "enabled" boolean NOT NULL DEFAULT (1), "eventTypes" text NOT NULL, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`, + `CREATE TABLE "notification_preference" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "channel" varchar CHECK( "channel" IN ('email','webhook') ) NOT NULL, "enabled" boolean NOT NULL DEFAULT true, "eventTypes" text NOT NULL, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)`, ); await queryRunner.query( - `CREATE TABLE "api_key" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "keyHash" varchar NOT NULL, "ownerUserId" varchar NOT NULL, "active" boolean NOT NULL DEFAULT (1), "revokedAt" datetime, "rateLimitPerMinute" integer NOT NULL DEFAULT (60), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_4aacb7c1641a74534c8a96c4dc9" UNIQUE ("keyHash"))`, + `CREATE TABLE "api_key" ("id" varchar PRIMARY KEY NOT NULL, "name" varchar NOT NULL, "keyHash" varchar NOT NULL, "ownerUserId" varchar NOT NULL, "active" boolean NOT NULL DEFAULT true, "revokedAt" timestamp, "rateLimitPerMinute" integer NOT NULL DEFAULT (60), "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "UQ_4aacb7c1641a74534c8a96c4dc9" UNIQUE ("keyHash"))`, ); await queryRunner.query( - `CREATE TABLE "admin_audit_log" ("id" varchar PRIMARY KEY NOT NULL, "actorId" varchar(64) NOT NULL, "actionType" varchar(64) NOT NULL, "resourceType" varchar(64) NOT NULL, "resourceId" varchar(128), "metadata" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')))`, + `CREATE TABLE "admin_audit_log" ("id" varchar PRIMARY KEY NOT NULL, "actorId" varchar(64) NOT NULL, "actionType" varchar(64) NOT NULL, "resourceType" varchar(64) NOT NULL, "resourceId" varchar(128), "metadata" text, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)`, ); await queryRunner.query( - `CREATE TABLE "webhooks" ("id" varchar PRIMARY KEY NOT NULL, "url" varchar NOT NULL, "secret" varchar NOT NULL, "events" text NOT NULL, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "userId" varchar NOT NULL)`, + `CREATE TABLE "webhooks" ("id" varchar PRIMARY KEY NOT NULL, "url" varchar NOT NULL, "secret" varchar NOT NULL, "events" text NOT NULL, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "userId" varchar NOT NULL)`, ); await queryRunner.query( - `CREATE TABLE "stellar_events" ("id" varchar PRIMARY KEY NOT NULL, "txHash" varchar(64) NOT NULL, "eventIndex" integer NOT NULL, "eventType" varchar CHECK( "eventType" IN ('ESCROW_CREATED','ESCROW_FUNDED','MILESTONE_RELEASED','ESCROW_COMPLETED','ESCROW_CANCELLED','DISPUTE_CREATED','DISPUTE_RESOLVED') ) NOT NULL, "escrowId" varchar, "ledger" integer NOT NULL, "timestamp" datetime NOT NULL, "rawPayload" text NOT NULL, "extractedFields" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "amount" decimal(18,7), "asset" varchar, "milestoneIndex" integer, "fromAddress" varchar, "toAddress" varchar, "reason" text, CONSTRAINT "UQ_c6a70c31de4c4d3b23e6229c515" UNIQUE ("txHash", "eventIndex"))`, + `CREATE TABLE "stellar_events" ("id" varchar PRIMARY KEY NOT NULL, "txHash" varchar(64) NOT NULL, "eventIndex" integer NOT NULL, "eventType" varchar CHECK( "eventType" IN ('ESCROW_CREATED','ESCROW_FUNDED','MILESTONE_RELEASED','ESCROW_COMPLETED','ESCROW_CANCELLED','DISPUTE_CREATED','DISPUTE_RESOLVED') ) NOT NULL, "escrowId" varchar, "ledger" integer NOT NULL, "timestamp" timestamp NOT NULL, "rawPayload" text NOT NULL, "extractedFields" text, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "amount" decimal(18,7), "asset" varchar, "milestoneIndex" integer, "fromAddress" varchar, "toAddress" varchar, "reason" text, CONSTRAINT "UQ_c6a70c31de4c4d3b23e6229c515" UNIQUE ("txHash", "eventIndex"))`, ); await queryRunner.query( `CREATE INDEX "IDX_33bcf3b402d8757d22c1cc1ad3" ON "stellar_events" ("txHash") `, @@ -46,7 +46,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { `CREATE INDEX "IDX_f8d00fffa3b5110edf867481dd" ON "stellar_events" ("timestamp") `, ); await queryRunner.query( - `CREATE TABLE "temporary_escrow_conditions" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "description" text NOT NULL, "type" varchar NOT NULL DEFAULT ('manual'), "isMet" boolean NOT NULL DEFAULT (0), "metAt" datetime, "metByUserId" varchar, "metadata" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "isFulfilled" boolean NOT NULL DEFAULT (0), "fulfilledAt" datetime, "fulfilledByUserId" varchar, "fulfillmentNotes" text, "fulfillmentEvidence" text, CONSTRAINT "FK_88456ecac834c788fc912233e05" FOREIGN KEY ("escrowId") REFERENCES "escrows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`, + `CREATE TABLE "temporary_escrow_conditions" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "description" text NOT NULL, "type" varchar NOT NULL DEFAULT ('manual'), "isMet" boolean NOT NULL DEFAULT false, "metAt" timestamp, "metByUserId" varchar, "metadata" text, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "isFulfilled" boolean NOT NULL DEFAULT false, "fulfilledAt" timestamp, "fulfilledByUserId" varchar, "fulfillmentNotes" text, "fulfillmentEvidence" text, CONSTRAINT "FK_88456ecac834c788fc912233e05" FOREIGN KEY ("escrowId") REFERENCES "escrows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`, ); await queryRunner.query( `INSERT INTO "temporary_escrow_conditions"("id", "escrowId", "description", "type", "isMet", "metAt", "metByUserId", "metadata", "createdAt", "updatedAt") SELECT "id", "escrowId", "description", "type", "isMet", "metAt", "metByUserId", "metadata", "createdAt", "updatedAt" FROM "escrow_conditions"`, @@ -62,7 +62,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { await queryRunner.query(`DROP INDEX "idx_escrows_expires_at"`); await queryRunner.query(`DROP INDEX "idx_escrows_creator_status_created"`); await queryRunner.query( - `CREATE TABLE "temporary_escrows" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text, "amount" decimal(18,7) NOT NULL, "asset" varchar NOT NULL DEFAULT ('XLM'), "status" varchar NOT NULL DEFAULT ('pending'), "type" varchar NOT NULL DEFAULT ('standard'), "creatorId" varchar NOT NULL, "expiresAt" datetime, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "releaseTransactionHash" varchar, "isReleased" boolean NOT NULL DEFAULT (0), "expirationNotifiedAt" datetime, "stellarTxHash" varchar, "fundedAt" datetime, CONSTRAINT "FK_b483b9f73c28476240bbc993d0b" FOREIGN KEY ("creatorId") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`, + `CREATE TABLE "temporary_escrows" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text, "amount" decimal(18,7) NOT NULL, "asset" varchar NOT NULL DEFAULT ('XLM'), "status" varchar NOT NULL DEFAULT ('pending'), "type" varchar NOT NULL DEFAULT ('standard'), "creatorId" varchar NOT NULL, "expiresAt" timestamp, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "releaseTransactionHash" varchar, "isReleased" boolean NOT NULL DEFAULT false, "expirationNotifiedAt" timestamp, "stellarTxHash" varchar, "fundedAt" timestamp, CONSTRAINT "FK_b483b9f73c28476240bbc993d0b" FOREIGN KEY ("creatorId") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`, ); await queryRunner.query( `INSERT INTO "temporary_escrows"("id", "title", "description", "amount", "asset", "status", "type", "creatorId", "expiresAt", "isActive", "createdAt", "updatedAt", "releaseTransactionHash", "isReleased", "expirationNotifiedAt") SELECT "id", "title", "description", "amount", "asset", "status", "type", "creatorId", "expiresAt", "isActive", "createdAt", "updatedAt", "releaseTransactionHash", "isReleased", "expirationNotifiedAt" FROM "escrows"`, @@ -90,7 +90,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { `CREATE INDEX "idx_escrows_creator_status_created" ON "escrows" ("creatorId", "status", "createdAt") `, ); await queryRunner.query( - `CREATE TABLE "temporary_users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, + `CREATE TABLE "temporary_users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, ); await queryRunner.query( `INSERT INTO "temporary_users"("id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role") SELECT "id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role" FROM "users"`, @@ -98,7 +98,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { await queryRunner.query(`DROP TABLE "users"`); await queryRunner.query(`ALTER TABLE "temporary_users" RENAME TO "users"`); await queryRunner.query( - `CREATE TABLE "temporary_disputes" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "filedByUserId" varchar NOT NULL, "reason" text NOT NULL, "evidence" text, "status" varchar NOT NULL DEFAULT ('open'), "resolvedByUserId" varchar, "resolutionNotes" text, "sellerPercent" decimal(5,2), "buyerPercent" decimal(5,2), "outcome" varchar, "resolvedAt" datetime, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "REL_05cc0a36ac22b4dc8a82211d2e" UNIQUE ("escrowId"), CONSTRAINT "FK_05cc0a36ac22b4dc8a82211d2ee" FOREIGN KEY ("escrowId") REFERENCES "escrows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_23f126d4aaaa9d67243895b784b" FOREIGN KEY ("filedByUserId") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT "FK_a2215614b176b851d3e431de9b9" FOREIGN KEY ("resolvedByUserId") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`, + `CREATE TABLE "temporary_disputes" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "filedByUserId" varchar NOT NULL, "reason" text NOT NULL, "evidence" text, "status" varchar NOT NULL DEFAULT ('open'), "resolvedByUserId" varchar, "resolutionNotes" text, "sellerPercent" decimal(5,2), "buyerPercent" decimal(5,2), "outcome" varchar, "resolvedAt" timestamp, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "REL_05cc0a36ac22b4dc8a82211d2e" UNIQUE ("escrowId"), CONSTRAINT "FK_05cc0a36ac22b4dc8a82211d2ee" FOREIGN KEY ("escrowId") REFERENCES "escrows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION, CONSTRAINT "FK_23f126d4aaaa9d67243895b784b" FOREIGN KEY ("filedByUserId") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT "FK_a2215614b176b851d3e431de9b9" FOREIGN KEY ("resolvedByUserId") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`, ); await queryRunner.query( `INSERT INTO "temporary_disputes"("id", "escrowId", "filedByUserId", "reason", "evidence", "status", "resolvedByUserId", "resolutionNotes", "sellerPercent", "buyerPercent", "outcome", "resolvedAt", "createdAt", "updatedAt") SELECT "id", "escrowId", "filedByUserId", "reason", "evidence", "status", "resolvedByUserId", "resolutionNotes", "sellerPercent", "buyerPercent", "outcome", "resolvedAt", "createdAt", "updatedAt" FROM "disputes"`, @@ -108,7 +108,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { `ALTER TABLE "temporary_disputes" RENAME TO "disputes"`, ); await queryRunner.query( - `CREATE TABLE "temporary_webhooks" ("id" varchar PRIMARY KEY NOT NULL, "url" varchar NOT NULL, "secret" varchar NOT NULL, "events" text NOT NULL, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "userId" varchar NOT NULL, CONSTRAINT "FK_7dbbb3fa9d7ccab4925a67af414" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`, + `CREATE TABLE "temporary_webhooks" ("id" varchar PRIMARY KEY NOT NULL, "url" varchar NOT NULL, "secret" varchar NOT NULL, "events" text NOT NULL, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "userId" varchar NOT NULL, CONSTRAINT "FK_7dbbb3fa9d7ccab4925a67af414" FOREIGN KEY ("userId") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`, ); await queryRunner.query( `INSERT INTO "temporary_webhooks"("id", "url", "secret", "events", "isActive", "createdAt", "updatedAt", "userId") SELECT "id", "url", "secret", "events", "isActive", "createdAt", "updatedAt", "userId" FROM "webhooks"`, @@ -124,7 +124,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { `ALTER TABLE "webhooks" RENAME TO "temporary_webhooks"`, ); await queryRunner.query( - `CREATE TABLE "webhooks" ("id" varchar PRIMARY KEY NOT NULL, "url" varchar NOT NULL, "secret" varchar NOT NULL, "events" text NOT NULL, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "userId" varchar NOT NULL)`, + `CREATE TABLE "webhooks" ("id" varchar PRIMARY KEY NOT NULL, "url" varchar NOT NULL, "secret" varchar NOT NULL, "events" text NOT NULL, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "userId" varchar NOT NULL)`, ); await queryRunner.query( `INSERT INTO "webhooks"("id", "url", "secret", "events", "isActive", "createdAt", "updatedAt", "userId") SELECT "id", "url", "secret", "events", "isActive", "createdAt", "updatedAt", "userId" FROM "temporary_webhooks"`, @@ -134,7 +134,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { `ALTER TABLE "disputes" RENAME TO "temporary_disputes"`, ); await queryRunner.query( - `CREATE TABLE "disputes" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "filedByUserId" varchar NOT NULL, "reason" text NOT NULL, "evidence" text, "status" varchar NOT NULL DEFAULT ('open'), "resolvedByUserId" varchar, "resolutionNotes" text, "sellerPercent" decimal(5,2), "buyerPercent" decimal(5,2), "outcome" varchar, "resolvedAt" datetime, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "REL_05cc0a36ac22b4dc8a82211d2e" UNIQUE ("escrowId"))`, + `CREATE TABLE "disputes" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "filedByUserId" varchar NOT NULL, "reason" text NOT NULL, "evidence" text, "status" varchar NOT NULL DEFAULT ('open'), "resolvedByUserId" varchar, "resolutionNotes" text, "sellerPercent" decimal(5,2), "buyerPercent" decimal(5,2), "outcome" varchar, "resolvedAt" timestamp, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "REL_05cc0a36ac22b4dc8a82211d2e" UNIQUE ("escrowId"))`, ); await queryRunner.query( `INSERT INTO "disputes"("id", "escrowId", "filedByUserId", "reason", "evidence", "status", "resolvedByUserId", "resolutionNotes", "sellerPercent", "buyerPercent", "outcome", "resolvedAt", "createdAt", "updatedAt") SELECT "id", "escrowId", "filedByUserId", "reason", "evidence", "status", "resolvedByUserId", "resolutionNotes", "sellerPercent", "buyerPercent", "outcome", "resolvedAt", "createdAt", "updatedAt" FROM "temporary_disputes"`, @@ -142,7 +142,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { await queryRunner.query(`DROP TABLE "temporary_disputes"`); await queryRunner.query(`ALTER TABLE "users" RENAME TO "temporary_users"`); await queryRunner.query( - `CREATE TABLE "users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, + `CREATE TABLE "users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, ); await queryRunner.query( `INSERT INTO "users"("id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role") SELECT "id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role" FROM "temporary_users"`, @@ -158,7 +158,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { `ALTER TABLE "escrows" RENAME TO "temporary_escrows"`, ); await queryRunner.query( - `CREATE TABLE "escrows" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text, "amount" decimal(18,7) NOT NULL, "asset" varchar NOT NULL DEFAULT ('XLM'), "status" varchar NOT NULL DEFAULT ('pending'), "type" varchar NOT NULL DEFAULT ('standard'), "creatorId" varchar NOT NULL, "expiresAt" datetime, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "releaseTransactionHash" varchar, "isReleased" boolean NOT NULL DEFAULT (0), "expirationNotifiedAt" datetime, CONSTRAINT "FK_b483b9f73c28476240bbc993d0b" FOREIGN KEY ("creatorId") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`, + `CREATE TABLE "escrows" ("id" varchar PRIMARY KEY NOT NULL, "title" varchar NOT NULL, "description" text, "amount" decimal(18,7) NOT NULL, "asset" varchar NOT NULL DEFAULT ('XLM'), "status" varchar NOT NULL DEFAULT ('pending'), "type" varchar NOT NULL DEFAULT ('standard'), "creatorId" varchar NOT NULL, "expiresAt" timestamp, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "releaseTransactionHash" varchar, "isReleased" boolean NOT NULL DEFAULT false, "expirationNotifiedAt" timestamp, CONSTRAINT "FK_b483b9f73c28476240bbc993d0b" FOREIGN KEY ("creatorId") REFERENCES "users" ("id") ON DELETE NO ACTION ON UPDATE NO ACTION)`, ); await queryRunner.query( `INSERT INTO "escrows"("id", "title", "description", "amount", "asset", "status", "type", "creatorId", "expiresAt", "isActive", "createdAt", "updatedAt", "releaseTransactionHash", "isReleased", "expirationNotifiedAt") SELECT "id", "title", "description", "amount", "asset", "status", "type", "creatorId", "expiresAt", "isActive", "createdAt", "updatedAt", "releaseTransactionHash", "isReleased", "expirationNotifiedAt" FROM "temporary_escrows"`, @@ -186,7 +186,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { `ALTER TABLE "escrow_conditions" RENAME TO "temporary_escrow_conditions"`, ); await queryRunner.query( - `CREATE TABLE "escrow_conditions" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "description" text NOT NULL, "type" varchar NOT NULL DEFAULT ('manual'), "isMet" boolean NOT NULL DEFAULT (0), "metAt" datetime, "metByUserId" varchar, "metadata" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "FK_88456ecac834c788fc912233e05" FOREIGN KEY ("escrowId") REFERENCES "escrows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`, + `CREATE TABLE "escrow_conditions" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "description" text NOT NULL, "type" varchar NOT NULL DEFAULT ('manual'), "isMet" boolean NOT NULL DEFAULT false, "metAt" timestamp, "metByUserId" varchar, "metadata" text, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "FK_88456ecac834c788fc912233e05" FOREIGN KEY ("escrowId") REFERENCES "escrows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`, ); await queryRunner.query( `INSERT INTO "escrow_conditions"("id", "escrowId", "description", "type", "isMet", "metAt", "metByUserId", "metadata", "createdAt", "updatedAt") SELECT "id", "escrowId", "description", "type", "isMet", "metAt", "metByUserId", "metadata", "createdAt", "updatedAt" FROM "temporary_escrow_conditions"`, @@ -205,7 +205,7 @@ export class InitialMigration1774364374006 implements MigrationInterface { await queryRunner.query(`DROP TABLE "disputes"`); await queryRunner.query(`ALTER TABLE "users" RENAME TO "temporary_users"`); await queryRunner.query( - `CREATE TABLE "users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, + `CREATE TABLE "users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, ); await queryRunner.query( `INSERT INTO "users"("id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role") SELECT "id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role" FROM "temporary_users"`, diff --git a/apps/backend/src/migrations/1774476566443-AddMilestoneProposals.ts b/apps/backend/src/migrations/1774476566443-AddMilestoneProposals.ts index fb9ef06c..3ea04390 100644 --- a/apps/backend/src/migrations/1774476566443-AddMilestoneProposals.ts +++ b/apps/backend/src/migrations/1774476566443-AddMilestoneProposals.ts @@ -5,7 +5,7 @@ export class AddMilestoneProposals1774476566443 implements MigrationInterface { public async up(queryRunner: QueryRunner): Promise { await queryRunner.query( - `CREATE TABLE "temporary_users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, + `CREATE TABLE "temporary_users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, ); await queryRunner.query( `INSERT INTO "temporary_users"("id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role") SELECT "id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role" FROM "users"`, @@ -13,7 +13,7 @@ export class AddMilestoneProposals1774476566443 implements MigrationInterface { await queryRunner.query(`DROP TABLE "users"`); await queryRunner.query(`ALTER TABLE "temporary_users" RENAME TO "users"`); await queryRunner.query( - `CREATE TABLE "temporary_escrow_conditions" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "description" text NOT NULL, "type" varchar NOT NULL DEFAULT ('manual'), "isMet" boolean NOT NULL DEFAULT (0), "metAt" datetime, "metByUserId" varchar, "metadata" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "isFulfilled" boolean NOT NULL DEFAULT (0), "fulfilledAt" datetime, "fulfilledByUserId" varchar, "fulfillmentNotes" text, "fulfillmentEvidence" text, "amount" decimal(18,7), "proposedAmount" decimal(18,7), "proposedDescription" text, "proposedByUserId" varchar, CONSTRAINT "FK_88456ecac834c788fc912233e05" FOREIGN KEY ("escrowId") REFERENCES "escrows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`, + `CREATE TABLE "temporary_escrow_conditions" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "description" text NOT NULL, "type" varchar NOT NULL DEFAULT ('manual'), "isMet" boolean NOT NULL DEFAULT false, "metAt" timestamp, "metByUserId" varchar, "metadata" text, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "isFulfilled" boolean NOT NULL DEFAULT false, "fulfilledAt" timestamp, "fulfilledByUserId" varchar, "fulfillmentNotes" text, "fulfillmentEvidence" text, "amount" decimal(18,7), "proposedAmount" decimal(18,7), "proposedDescription" text, "proposedByUserId" varchar, CONSTRAINT "FK_88456ecac834c788fc912233e05" FOREIGN KEY ("escrowId") REFERENCES "escrows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`, ); await queryRunner.query( `INSERT INTO "temporary_escrow_conditions"("id", "escrowId", "description", "type", "isMet", "metAt", "metByUserId", "metadata", "createdAt", "updatedAt", "isFulfilled", "fulfilledAt", "fulfilledByUserId", "fulfillmentNotes", "fulfillmentEvidence") SELECT "id", "escrowId", "description", "type", "isMet", "metAt", "metByUserId", "metadata", "createdAt", "updatedAt", "isFulfilled", "fulfilledAt", "fulfilledByUserId", "fulfillmentNotes", "fulfillmentEvidence" FROM "escrow_conditions"`, @@ -23,7 +23,7 @@ export class AddMilestoneProposals1774476566443 implements MigrationInterface { `ALTER TABLE "temporary_escrow_conditions" RENAME TO "escrow_conditions"`, ); await queryRunner.query( - `CREATE TABLE "temporary_users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, + `CREATE TABLE "temporary_users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, ); await queryRunner.query( `INSERT INTO "temporary_users"("id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role") SELECT "id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role" FROM "users"`, @@ -31,7 +31,7 @@ export class AddMilestoneProposals1774476566443 implements MigrationInterface { await queryRunner.query(`DROP TABLE "users"`); await queryRunner.query(`ALTER TABLE "temporary_users" RENAME TO "users"`); await queryRunner.query( - `CREATE TABLE "temporary_notification" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "eventType" varchar CHECK( "eventType" IN ('ESCROW_CREATED','ESCROW_FUNDED','MILESTONE_RELEASED','ESCROW_COMPLETED','ESCROW_CANCELLED','DISPUTE_RAISED','DISPUTE_RESOLVED','ESCROW_EXPIRED','CONDITION_FULFILLED','CONDITION_CONFIRMED','EXPIRATION_WARNING') ) NOT NULL, "payload" text NOT NULL, "status" varchar CHECK( "status" IN ('pending','sent','failed') ) NOT NULL DEFAULT ('pending'), "retryCount" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`, + `CREATE TABLE "temporary_notification" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "eventType" varchar CHECK( "eventType" IN ('ESCROW_CREATED','ESCROW_FUNDED','MILESTONE_RELEASED','ESCROW_COMPLETED','ESCROW_CANCELLED','DISPUTE_RAISED','DISPUTE_RESOLVED','ESCROW_EXPIRED','CONDITION_FULFILLED','CONDITION_CONFIRMED','EXPIRATION_WARNING') ) NOT NULL, "payload" text NOT NULL, "status" varchar CHECK( "status" IN ('pending','sent','failed') ) NOT NULL DEFAULT ('pending'), "retryCount" integer NOT NULL DEFAULT (0), "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)`, ); await queryRunner.query( `INSERT INTO "temporary_notification"("id", "userId", "eventType", "payload", "status", "retryCount", "createdAt", "updatedAt") SELECT "id", "userId", "eventType", "payload", "status", "retryCount", "createdAt", "updatedAt" FROM "notification"`, @@ -47,7 +47,7 @@ export class AddMilestoneProposals1774476566443 implements MigrationInterface { `ALTER TABLE "notification" RENAME TO "temporary_notification"`, ); await queryRunner.query( - `CREATE TABLE "notification" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "eventType" varchar CHECK( "eventType" IN ('ESCROW_CREATED','ESCROW_FUNDED','MILESTONE_RELEASED','ESCROW_COMPLETED','ESCROW_CANCELLED','DISPUTE_RAISED','DISPUTE_RESOLVED','ESCROW_EXPIRED') ) NOT NULL, "payload" text NOT NULL, "status" varchar CHECK( "status" IN ('pending','sent','failed') ) NOT NULL DEFAULT ('pending'), "retryCount" integer NOT NULL DEFAULT (0), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')))`, + `CREATE TABLE "notification" ("id" varchar PRIMARY KEY NOT NULL, "userId" varchar NOT NULL, "eventType" varchar CHECK( "eventType" IN ('ESCROW_CREATED','ESCROW_FUNDED','MILESTONE_RELEASED','ESCROW_COMPLETED','ESCROW_CANCELLED','DISPUTE_RAISED','DISPUTE_RESOLVED','ESCROW_EXPIRED') ) NOT NULL, "payload" text NOT NULL, "status" varchar CHECK( "status" IN ('pending','sent','failed') ) NOT NULL DEFAULT ('pending'), "retryCount" integer NOT NULL DEFAULT (0), "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP)`, ); await queryRunner.query( `INSERT INTO "notification"("id", "userId", "eventType", "payload", "status", "retryCount", "createdAt", "updatedAt") SELECT "id", "userId", "eventType", "payload", "status", "retryCount", "createdAt", "updatedAt" FROM "temporary_notification"`, @@ -55,7 +55,7 @@ export class AddMilestoneProposals1774476566443 implements MigrationInterface { await queryRunner.query(`DROP TABLE "temporary_notification"`); await queryRunner.query(`ALTER TABLE "users" RENAME TO "temporary_users"`); await queryRunner.query( - `CREATE TABLE "users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, + `CREATE TABLE "users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, ); await queryRunner.query( `INSERT INTO "users"("id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role") SELECT "id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role" FROM "temporary_users"`, @@ -65,7 +65,7 @@ export class AddMilestoneProposals1774476566443 implements MigrationInterface { `ALTER TABLE "escrow_conditions" RENAME TO "temporary_escrow_conditions"`, ); await queryRunner.query( - `CREATE TABLE "escrow_conditions" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "description" text NOT NULL, "type" varchar NOT NULL DEFAULT ('manual'), "isMet" boolean NOT NULL DEFAULT (0), "metAt" datetime, "metByUserId" varchar, "metadata" text, "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "isFulfilled" boolean NOT NULL DEFAULT (0), "fulfilledAt" datetime, "fulfilledByUserId" varchar, "fulfillmentNotes" text, "fulfillmentEvidence" text, CONSTRAINT "FK_88456ecac834c788fc912233e05" FOREIGN KEY ("escrowId") REFERENCES "escrows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`, + `CREATE TABLE "escrow_conditions" ("id" varchar PRIMARY KEY NOT NULL, "escrowId" varchar NOT NULL, "description" text NOT NULL, "type" varchar NOT NULL DEFAULT ('manual'), "isMet" boolean NOT NULL DEFAULT false, "metAt" timestamp, "metByUserId" varchar, "metadata" text, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "isFulfilled" boolean NOT NULL DEFAULT false, "fulfilledAt" timestamp, "fulfilledByUserId" varchar, "fulfillmentNotes" text, "fulfillmentEvidence" text, CONSTRAINT "FK_88456ecac834c788fc912233e05" FOREIGN KEY ("escrowId") REFERENCES "escrows" ("id") ON DELETE CASCADE ON UPDATE NO ACTION)`, ); await queryRunner.query( `INSERT INTO "escrow_conditions"("id", "escrowId", "description", "type", "isMet", "metAt", "metByUserId", "metadata", "createdAt", "updatedAt", "isFulfilled", "fulfilledAt", "fulfilledByUserId", "fulfillmentNotes", "fulfillmentEvidence") SELECT "id", "escrowId", "description", "type", "isMet", "metAt", "metByUserId", "metadata", "createdAt", "updatedAt", "isFulfilled", "fulfilledAt", "fulfilledByUserId", "fulfillmentNotes", "fulfillmentEvidence" FROM "temporary_escrow_conditions"`, @@ -73,7 +73,7 @@ export class AddMilestoneProposals1774476566443 implements MigrationInterface { await queryRunner.query(`DROP TABLE "temporary_escrow_conditions"`); await queryRunner.query(`ALTER TABLE "users" RENAME TO "temporary_users"`); await queryRunner.query( - `CREATE TABLE "users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT (1), "createdAt" datetime NOT NULL DEFAULT (datetime('now')), "updatedAt" datetime NOT NULL DEFAULT (datetime('now')), "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, + `CREATE TABLE "users" ("id" varchar PRIMARY KEY NOT NULL, "walletAddress" varchar NOT NULL, "nonce" varchar, "isActive" boolean NOT NULL DEFAULT true, "createdAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, "role" varchar CHECK( "role" IN ('USER','ADMIN','SUPER_ADMIN') ) NOT NULL DEFAULT ('USER'), CONSTRAINT "UQ_fc71cd6fb73f95244b23e2ef113" UNIQUE ("walletAddress"))`, ); await queryRunner.query( `INSERT INTO "users"("id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role") SELECT "id", "walletAddress", "nonce", "isActive", "createdAt", "updatedAt", "role" FROM "temporary_users"`, diff --git a/apps/frontend/package-lock.json b/apps/frontend/package-lock.json index 29280d79..f8b6a8d9 100644 --- a/apps/frontend/package-lock.json +++ b/apps/frontend/package-lock.json @@ -4950,6 +4950,70 @@ "node": ">=14.0.0" } }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/core": { + "version": "1.8.1", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/wasi-threads": "1.1.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/runtime": { + "version": "1.8.1", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@emnapi/wasi-threads": { + "version": "1.1.0", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@napi-rs/wasm-runtime": { + "version": "1.1.1", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "@emnapi/core": "^1.7.1", + "@emnapi/runtime": "^1.7.1", + "@tybys/wasm-util": "^0.10.1" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/@tybys/wasm-util": { + "version": "0.10.1", + "dev": true, + "inBundle": true, + "license": "MIT", + "optional": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@tailwindcss/oxide-wasm32-wasi/node_modules/tslib": { + "version": "2.8.1", + "dev": true, + "inBundle": true, + "license": "0BSD", + "optional": true + }, "node_modules/@tailwindcss/oxide-win32-arm64-msvc": { "version": "4.2.4", "resolved": "https://registry.npmjs.org/@tailwindcss/oxide-win32-arm64-msvc/-/oxide-win32-arm64-msvc-4.2.4.tgz", @@ -13852,6 +13916,7 @@ "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, diff --git a/package-lock.json b/package-lock.json index 6b34b4ae..400538b7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -263,7 +263,6 @@ "integrity": "sha512-klQbnPAAiGYFyI02+znpBRLyjL4/BrBd0nyWkdC0s/6xFLkXYQ8OoRrSkqacS1ddVxf/LDyODIKbQ5TgKAf/Fg==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@typescript-eslint/scope-manager": "8.56.1", "@typescript-eslint/types": "8.56.1", @@ -455,7 +454,6 @@ "integrity": "sha512-UVJyE9MttOsBQIDKw1skb9nAwQuR5wuGD3+82K6JgJlm/Y+KI92oNsMNGZCYdDsVtRHSak0pcV5Dno5+4jh9sw==", "dev": true, "license": "MIT", - "peer": true, "bin": { "acorn": "bin/acorn" }, @@ -682,7 +680,6 @@ "integrity": "sha512-uYixubwmqJZH+KLVYIVKY1JQt7tysXhtj21WSvjcSmU5SVNzMus1bgLe+pAt816yQ8opKfheVVoPLqvVMGejYw==", "dev": true, "license": "MIT", - "peer": true, "dependencies": { "@eslint-community/eslint-utils": "^4.8.0", "@eslint-community/regexpp": "^4.12.2", @@ -1350,7 +1347,6 @@ "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", - "peer": true, "engines": { "node": ">=12" }, @@ -1374,7 +1370,6 @@ "integrity": "sha512-UOnG6LftzbdaHZcKoPFtOcCKztrQ57WkHDeRD9t/PTQtmT0NHSeWWepj6pS0z/N7+08BHFDQVUrfmfMRcZwbMg==", "dev": true, "license": "MIT", - "peer": true, "bin": { "prettier": "bin/prettier.cjs" },