diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1694691302615-InitialMigration.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1694691302615-InitialMigration.ts deleted file mode 100644 index 6401a7d909..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1694691302615-InitialMigration.ts +++ /dev/null @@ -1,66 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; -import { DATABASE_SCHEMA_NAME } from '../../common/constants'; - -export class InitialMigration1694776006387 implements MigrationInterface { - name = 'InitialMigration1694776006387'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.createSchema(DATABASE_SCHEMA_NAME, true); - await queryRunner.query( - `CREATE TYPE "hmt"."tokens_token_type_enum" AS ENUM('EMAIL', 'PASSWORD')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."tokens" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "uuid" uuid NOT NULL DEFAULT uuid_generate_v4(), "token_type" "hmt"."tokens_token_type_enum" NOT NULL, "user_id" integer NOT NULL, CONSTRAINT "UQ_57b0dd7af7c6a0b7d4c3fd5c464" UNIQUE ("uuid"), CONSTRAINT "REL_8769073e38c365f315426554ca" UNIQUE ("user_id"), CONSTRAINT "PK_3001e89ada36263dabf1fb6210a" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."users_type_enum" AS ENUM('OPERATOR', 'REQUESTER')`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."users_status_enum" AS ENUM('ACTIVE', 'INACTIVE', 'PENDING')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."users" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "password" character varying NOT NULL, "email" character varying, "type" "hmt"."users_type_enum" NOT NULL, "status" "hmt"."users_status_enum" NOT NULL, CONSTRAINT "UQ_97672ac88f789774dd47f7c8be3" UNIQUE ("email"), CONSTRAINT "PK_a3ffb1c0c8416b9fc6f907b7433" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."auths" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "access_token" character varying NOT NULL, "refresh_token" character varying NOT NULL, "user_id" integer NOT NULL, CONSTRAINT "REL_593ea7ee438b323776029d3185" UNIQUE ("user_id"), CONSTRAINT "PK_22fc0631a651972ddc9c5a31090" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."reputation_type_enum" AS ENUM('WORKER', 'JOB_LAUNCHER', 'EXCHANGE_ORACLE', 'RECORDING_ORACLE', 'REPUTATION_ORACLE')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."reputation" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "chain_id" integer NOT NULL, "address" character varying NOT NULL, "reputation_points" integer NOT NULL, "type" "hmt"."reputation_type_enum" NOT NULL, CONSTRAINT "PK_640807583e8622e1d9bbe6f1b7b" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."webhook_incoming_status_enum" AS ENUM('PENDING', 'COMPLETED', 'FAILED', 'PAID')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."webhook_incoming" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "chain_id" integer NOT NULL, "oracle_address" character varying, "escrow_address" character varying NOT NULL, "results_url" character varying, "check_passed" boolean, "retries_count" integer NOT NULL, "wait_until" TIMESTAMP WITH TIME ZONE NOT NULL, "status" "hmt"."webhook_incoming_status_enum" NOT NULL, CONSTRAINT "PK_08e16abccb4720323203bf8f7a0" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" ADD CONSTRAINT "FK_8769073e38c365f315426554ca5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."auths" ADD CONSTRAINT "FK_593ea7ee438b323776029d3185f" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."auths" DROP CONSTRAINT "FK_593ea7ee438b323776029d3185f"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" DROP CONSTRAINT "FK_8769073e38c365f315426554ca5"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."webhook_incoming"`); - await queryRunner.query(`DROP TYPE "hmt"."webhook_incoming_status_enum"`); - await queryRunner.query(`DROP TABLE "hmt"."reputation"`); - await queryRunner.query(`DROP TYPE "hmt"."reputation_type_enum"`); - await queryRunner.query(`DROP TABLE "hmt"."auths"`); - await queryRunner.query(`DROP TABLE "hmt"."users"`); - await queryRunner.query(`DROP TYPE "hmt"."users_status_enum"`); - await queryRunner.query(`DROP TYPE "hmt"."users_type_enum"`); - await queryRunner.query(`DROP TABLE "hmt"."tokens"`); - await queryRunner.query(`DROP TYPE "hmt"."tokens_token_type_enum"`); - await queryRunner.dropSchema(DATABASE_SCHEMA_NAME); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1698930021242-AddWeb3PropertiesToUser.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1698930021242-AddWeb3PropertiesToUser.ts deleted file mode 100644 index a956311c69..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1698930021242-AddWeb3PropertiesToUser.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddWeb3PropertiesToUser1698930021242 - implements MigrationInterface -{ - name = 'AddWeb3PropertiesToUser1698930021242'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."users" ADD "evm_address" character varying`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ADD CONSTRAINT "UQ_6009c050ae797d7e13ba0b0759b" UNIQUE ("evm_address")`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ADD "nonce" character varying`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ALTER COLUMN "password" DROP NOT NULL`, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."users_type_enum" RENAME TO "users_type_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."users_type_enum" AS ENUM('OPERATOR', 'EXCHANGE_ORACLE', 'RECORDING_ORACLE', 'WORKER')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ALTER COLUMN "type" TYPE "hmt"."users_type_enum" USING "type"::"text"::"hmt"."users_type_enum"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."users_type_enum_old"`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."users_type_enum_old" AS ENUM('OPERATOR', 'REQUESTER')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ALTER COLUMN "type" TYPE "hmt"."users_type_enum_old" USING "type"::"text"::"hmt"."users_type_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."users_type_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."users_type_enum_old" RENAME TO "users_type_enum"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ALTER COLUMN "password" SET NOT NULL`, - ); - await queryRunner.query(`ALTER TABLE "hmt"."users" DROP COLUMN "nonce"`); - await queryRunner.query( - `ALTER TABLE "hmt"."users" DROP CONSTRAINT "UQ_6009c050ae797d7e13ba0b0759b"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" DROP COLUMN "evm_address"`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1699287419841-uniqueEntryWehbookIncoming.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1699287419841-uniqueEntryWehbookIncoming.ts deleted file mode 100644 index acf91588d0..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1699287419841-uniqueEntryWehbookIncoming.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class UniqueEntryWehbookIncoming1699287419841 - implements MigrationInterface -{ - name = 'UniqueEntryWehbookIncoming1699287419841'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TYPE "hmt"."users_type_enum" RENAME TO "users_type_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."users_type_enum" AS ENUM('OPERATOR', 'EXCHANGE_ORACLE', 'RECORDING_ORACLE', 'WORKER')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ALTER COLUMN "type" TYPE "hmt"."users_type_enum" USING "type"::"text"::"hmt"."users_type_enum"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."users_type_enum_old"`); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_ed1eb73afbf214f9bd4c2d03f4" ON "hmt"."webhook_incoming" ("chain_id", "escrow_address") `, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `DROP INDEX "hmt"."IDX_ed1eb73afbf214f9bd4c2d03f4"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."users_type_enum_old" AS ENUM('OPERATOR', 'REQUESTER')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ALTER COLUMN "type" TYPE "hmt"."users_type_enum_old" USING "type"::"text"::"hmt"."users_type_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."users_type_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."users_type_enum_old" RENAME TO "users_type_enum"`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1706196712859-AddKycTable.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1706196712859-AddKycTable.ts deleted file mode 100644 index 752b0a853b..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1706196712859-AddKycTable.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddKycTable1706196712859 implements MigrationInterface { - name = 'AddKycTable1706196712859'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."kycs_status_enum" AS ENUM('NONE', 'APPROVED', 'SUBMISSION_REQUIRED', 'RESUBMISSION_REQUIRED', 'REJECTED', 'PENDING_VERIFICATION', 'RESET')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."kycs" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "session_id" character varying NOT NULL, "status" "hmt"."kycs_status_enum" NOT NULL DEFAULT 'NONE', "message" character varying, "user_id" integer NOT NULL, CONSTRAINT "UQ_76ea5d4f1a010a5fe4949771f4c" UNIQUE ("session_id"), CONSTRAINT "REL_bbfe1fa864841e82cff1be09e8" UNIQUE ("user_id"), CONSTRAINT "PK_6f4a4d2b94576014ab3d5e77694" PRIMARY KEY ("id", "session_id"))`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ADD CONSTRAINT "FK_bbfe1fa864841e82cff1be09e8b" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" DROP CONSTRAINT "FK_bbfe1fa864841e82cff1be09e8b"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."kycs"`); - await queryRunner.query(`DROP TYPE "hmt"."kycs_status_enum"`); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1707377515450-AddCronJobTable.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1707377515450-AddCronJobTable.ts deleted file mode 100644 index cdad9531ee..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1707377515450-AddCronJobTable.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddCronJobTable1707377515450 implements MigrationInterface { - name = 'AddCronJobTable1707377515450'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum" AS ENUM( - 'process-pending-webhook', - 'process-paid-webhook' - ) - `); - await queryRunner.query(` - CREATE TABLE "hmt"."cron-jobs" ( - "id" SERIAL NOT NULL, - "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, - "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, - "cron_job_type" "hmt"."cron-jobs_cron_job_type_enum" NOT NULL, - "started_at" TIMESTAMP WITH TIME ZONE NOT NULL, - "completed_at" TIMESTAMP WITH TIME ZONE, - CONSTRAINT "PK_268498ac0d3e7472960fb0faeb1" PRIMARY KEY ("id") - ) - `); - await queryRunner.query(` - CREATE UNIQUE INDEX "IDX_0dafd70b737e71d21490ad0126" ON "hmt"."cron-jobs" ("cron_job_type") - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - DROP INDEX "hmt"."IDX_0dafd70b737e71d21490ad0126" - `); - await queryRunner.query(` - DROP TABLE "hmt"."cron-jobs" - `); - await queryRunner.query(` - DROP TYPE "hmt"."cron-jobs_cron_job_type_enum" - `); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1709188760416-DropCheckPassedColumnFromWebhookIncoming.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1709188760416-DropCheckPassedColumnFromWebhookIncoming.ts deleted file mode 100644 index aba12e81e8..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1709188760416-DropCheckPassedColumnFromWebhookIncoming.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { MigrationInterface, QueryRunner, TableColumn } from 'typeorm'; - -export class DropCheckPassedColumnFromWebhookIncoming1709188760416 - implements MigrationInterface -{ - name = 'DropCheckPassedColumnFromWebhookIncoming1709188760416'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.dropColumn('hmt.webhook_incoming', 'check_passed'); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.addColumn( - 'hmt.webhook_incoming', - new TableColumn({ - name: 'check_passed', - type: 'boolean', - isNullable: true, - }), - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1711022497871-RefactorAuth.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1711022497871-RefactorAuth.ts deleted file mode 100644 index 8e18f7fe43..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1711022497871-RefactorAuth.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class RefactorAuth1711022497871 implements MigrationInterface { - name = 'RefactorAuth1711022497871'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" DROP COLUMN "token_type"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."tokens_token_type_enum"`); - await queryRunner.query( - `CREATE TYPE "hmt"."tokens_type_enum" AS ENUM('EMAIL', 'PASSWORD', 'REFRESH')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" ADD "type" "hmt"."tokens_type_enum" NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" ADD "expires_at" TIMESTAMP WITH TIME ZONE NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" DROP CONSTRAINT "FK_8769073e38c365f315426554ca5"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" DROP CONSTRAINT "REL_8769073e38c365f315426554ca"`, - ); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_306030d9411d291750fd115857" ON "hmt"."tokens" ("type", "user_id") `, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" ADD CONSTRAINT "FK_8769073e38c365f315426554ca5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" DROP CONSTRAINT "FK_8769073e38c365f315426554ca5"`, - ); - await queryRunner.query( - `DROP INDEX "hmt"."IDX_306030d9411d291750fd115857"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" ADD CONSTRAINT "REL_8769073e38c365f315426554ca" UNIQUE ("user_id")`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" ADD CONSTRAINT "FK_8769073e38c365f315426554ca5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" DROP COLUMN "expires_at"`, - ); - await queryRunner.query(`ALTER TABLE "hmt"."tokens" DROP COLUMN "type"`); - await queryRunner.query(`DROP TYPE "hmt"."tokens_type_enum"`); - await queryRunner.query( - `CREATE TYPE "hmt"."tokens_token_type_enum" AS ENUM('EMAIL', 'PASSWORD')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" ADD "token_type" "hmt"."tokens_token_type_enum" NOT NULL`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1712220998800-removeOracleAddress.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1712220998800-removeOracleAddress.ts deleted file mode 100644 index ce0a0ef700..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1712220998800-removeOracleAddress.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class RemoveOracleAddress1712220998800 implements MigrationInterface { - name = 'RemoveOracleAddress1712220998800'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."webhook_incoming" DROP COLUMN "oracle_address"`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."webhook_incoming" ADD "oracle_address" character varying`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1715102477041-AddSiteKeysTable.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1715102477041-AddSiteKeysTable.ts deleted file mode 100644 index e421f3c09b..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1715102477041-AddSiteKeysTable.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddSiteKeysTable1715102477041 implements MigrationInterface { - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."site_keys_type_enum" AS ENUM('fortune', 'cvat', 'hcaptcha')`, - ); - - await queryRunner.query(` - CREATE TABLE "hmt"."site_keys" ( - id SERIAL PRIMARY KEY, - site_key VARCHAR UNIQUE NOT NULL, - type "hmt"."site_keys_type_enum" NOT NULL, - user_id INTEGER UNIQUE, - created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, - updated_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP - ); - `); - - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ADD CONSTRAINT "FK_178ba06ffb4808dbb40e782231e" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - - await queryRunner.query(` - CREATE UNIQUE INDEX "IDX_031d62ae4b47ae1a15c3d68179" ON "hmt"."site_keys" ("site_key", "type") - `); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(` - DROP INDEX "hmt"."IDX_031d62ae4b47ae1a15c3d68179" - `); - - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" DROP CONSTRAINT "FK_178ba06ffb4808dbb40e782231e"`, - ); - - await queryRunner.query(` - DROP TABLE "hmt"."site_keys"; - `); - - await queryRunner.query(`DROP TYPE "hmt"."site_keys_type_enum"`); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1715610735337-CredentialsSetup.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1715610735337-CredentialsSetup.ts deleted file mode 100644 index e4294d7ce2..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1715610735337-CredentialsSetup.ts +++ /dev/null @@ -1,61 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class CredentialsSetup1715610735337 implements MigrationInterface { - name = 'CredentialsSetup1715610735337'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."credentials_status_enum" AS ENUM('ACTIVE', 'EXPIRED', 'VALIDATED', 'ON_CHAIN')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."credentials" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "reference" character varying NOT NULL, "description" text NOT NULL, "url" character varying NOT NULL, "status" "hmt"."credentials_status_enum" NOT NULL, "starts_at" TIMESTAMP WITH TIME ZONE NOT NULL, "expires_at" TIMESTAMP WITH TIME ZONE, CONSTRAINT "UQ_481aa1ff346d6eee7656880c568" UNIQUE ("reference"), CONSTRAINT "PK_1e38bc43be6697cdda548ad27a6" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."credential_validations_status_enum" AS ENUM('VALIDATED', 'ON_CHAIN')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."credential_validations" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "status" "hmt"."credential_validations_status_enum" NOT NULL, "certificate" character varying, "credential_id" integer, "user_id" integer, CONSTRAINT "PK_ea03b6fbdfcddca7c2625f6a091" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."reputation_type_enum" RENAME TO "reputation_type_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."reputation_type_enum" AS ENUM('WORKER', 'JOB_LAUNCHER', 'EXCHANGE_ORACLE', 'RECORDING_ORACLE', 'REPUTATION_ORACLE', 'CREDENTIAL_VALIDATOR')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."reputation" ALTER COLUMN "type" TYPE "hmt"."reputation_type_enum" USING "type"::"text"::"hmt"."reputation_type_enum"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."reputation_type_enum_old"`); - await queryRunner.query( - `ALTER TABLE "hmt"."credential_validations" ADD CONSTRAINT "FK_a546350ec2c97f067c802ff672a" FOREIGN KEY ("credential_id") REFERENCES "hmt"."credentials"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."credential_validations" ADD CONSTRAINT "FK_d1896792b36ed073631703df40a" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."credential_validations" DROP CONSTRAINT "FK_d1896792b36ed073631703df40a"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."credential_validations" DROP CONSTRAINT "FK_a546350ec2c97f067c802ff672a"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."reputation_type_enum_old" AS ENUM('WORKER', 'JOB_LAUNCHER', 'EXCHANGE_ORACLE', 'RECORDING_ORACLE', 'REPUTATION_ORACLE')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."reputation" ALTER COLUMN "type" TYPE "hmt"."reputation_type_enum_old" USING "type"::"text"::"hmt"."reputation_type_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."reputation_type_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."reputation_type_enum_old" RENAME TO "reputation_type_enum"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."credential_validations"`); - await queryRunner.query( - `DROP TYPE "hmt"."credential_validations_status_enum"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."credentials"`); - await queryRunner.query(`DROP TYPE "hmt"."credentials_status_enum"`); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1716713759414-AddCountryColumnToKyc.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1716713759414-AddCountryColumnToKyc.ts deleted file mode 100644 index be0ec02c75..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1716713759414-AddCountryColumnToKyc.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddCountryColumnToKyc1716713759414 implements MigrationInterface { - name = 'AddCountryColumnToKyc1716713759414'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ADD "country" character varying NULL`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "hmt"."kycs" DROP COLUMN "country"`); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1718897436892-dropAuthsTable.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1718897436892-dropAuthsTable.ts deleted file mode 100644 index 5a26afd117..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1718897436892-dropAuthsTable.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class DropAuthsTable1718897436892 implements MigrationInterface { - name = 'DropAuthsTable1718897436892'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."auths" DROP CONSTRAINT "FK_593ea7ee438b323776029d3185f"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."auths"`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TABLE "hmt"."auths" ( - "id" SERIAL NOT NULL, - "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, - "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, - "access_token" character varying NOT NULL, - "refresh_token" character varying NOT NULL, - "user_id" integer NOT NULL, - CONSTRAINT "REL_593ea7ee438b323776029d3185" UNIQUE ("user_id"), - CONSTRAINT "PK_22fc0631a651972ddc9c5a31090" PRIMARY KEY ("id") - )`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."auths" ADD CONSTRAINT "FK_593ea7ee438b323776029d3185f" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1718970966064-RenameAndModifyUserRoleEnum.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1718970966064-RenameAndModifyUserRoleEnum.ts deleted file mode 100644 index ffa17fc45f..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1718970966064-RenameAndModifyUserRoleEnum.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class RenameAndModifyUserRoleEnum1718970966064 - implements MigrationInterface -{ - name = 'RenameAndModifyUserRoleEnum1718970966064'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" DROP CONSTRAINT "FK_178ba06ffb4808dbb40e782231e"`, - ); - await queryRunner.query( - `DROP INDEX "hmt"."IDX_031d62ae4b47ae1a15c3d68179"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ALTER COLUMN "created_at" DROP DEFAULT`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ALTER COLUMN "updated_at" DROP DEFAULT`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" RENAME COLUMN "type" TO "role"`, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."users_type_enum" RENAME TO "users_type_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."users_role_enum" AS ENUM('OPERATOR', 'WORKER', 'HUMAN_APP', 'ADMIN')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ALTER COLUMN "role" TYPE "hmt"."users_role_enum" USING "role"::"text"::"hmt"."users_role_enum"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."users_type_enum_old"`); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_271231e19f913b8a0cf028e9e7" ON "hmt"."site_keys" ("site_key", "type") `, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ADD CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" DROP CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c"`, - ); - await queryRunner.query( - `DROP INDEX "hmt"."IDX_271231e19f913b8a0cf028e9e7"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."users_type_enum_old" AS ENUM('OPERATOR', 'WORKER', 'HUMAN_APP', 'ADMIN')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ALTER COLUMN "role" TYPE "hmt"."users_type_enum_old" USING "role"::"text"::"hmt"."users_type_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."users_role_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."users_type_enum_old" RENAME TO "users_type_enum"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ALTER COLUMN "updated_at" SET DEFAULT CURRENT_TIMESTAMP`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ALTER COLUMN "created_at" SET DEFAULT CURRENT_TIMESTAMP`, - ); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_031d62ae4b47ae1a15c3d68179" ON "hmt"."site_keys" ("site_key", "type") `, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ADD CONSTRAINT "FK_178ba06ffb4808dbb40e782231e" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" RENAME COLUMN "role" TO "type"`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1719922587868-AddKYCStatusError.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1719922587868-AddKYCStatusError.ts deleted file mode 100644 index 87721666e7..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1719922587868-AddKYCStatusError.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddKYCStatusError1719922587868 implements MigrationInterface { - name = 'AddKYCStatusError1719922587868'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TYPE "hmt"."kycs_status_enum" RENAME TO "kycs_status_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."kycs_status_enum" AS ENUM('NONE', 'APPROVED', 'SUBMISSION_REQUIRED', 'RESUBMISSION_REQUIRED', 'REJECTED', 'PENDING_VERIFICATION', 'RESET', 'ERROR')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" DROP DEFAULT`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" TYPE "hmt"."kycs_status_enum" USING "status"::"text"::"hmt"."kycs_status_enum"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" SET DEFAULT 'NONE'`, - ); - await queryRunner.query(`DROP TYPE "hmt"."kycs_status_enum_old"`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."kycs_status_enum_old" AS ENUM('NONE', 'APPROVED', 'SUBMISSION_REQUIRED', 'RESUBMISSION_REQUIRED', 'REJECTED', 'PENDING_VERIFICATION', 'RESET')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" DROP DEFAULT`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" TYPE "hmt"."kycs_status_enum_old" USING "status"::"text"::"hmt"."kycs_status_enum_old"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" SET DEFAULT 'NONE'`, - ); - await queryRunner.query(`DROP TYPE "hmt"."kycs_status_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."kycs_status_enum_old" RENAME TO "kycs_status_enum"`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1720093298582-AddQualification.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1720093298582-AddQualification.ts deleted file mode 100644 index e7b1ecd689..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1720093298582-AddQualification.ts +++ /dev/null @@ -1,37 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddQualification1720093298582 implements MigrationInterface { - name = 'AddQualification1720093298582'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TABLE "hmt"."qualifications" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "reference" character varying NOT NULL, "title" text NOT NULL, "description" text NOT NULL, "expires_at" TIMESTAMP, CONSTRAINT "UQ_f9c59623bb945337cd22c538d2b" UNIQUE ("reference"), CONSTRAINT "PK_9ed4d526ac3b76ba3f1c1080433" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_f9c59623bb945337cd22c538d2" ON "hmt"."qualifications" ("reference") `, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."user_qualifications" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "user_id" integer, "qualification_id" integer, CONSTRAINT "PK_4b567ea1379253b4edbec543a08" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_bfa80c2767c180533958bf9c971" FOREIGN KEY ("qualification_id") REFERENCES "hmt"."qualifications"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_bfa80c2767c180533958bf9c971"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."user_qualifications"`); - await queryRunner.query( - `DROP INDEX "hmt"."IDX_f9c59623bb945337cd22c538d2"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."qualifications"`); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1721361395971-AddNewTypeAndUpdatedUniqueKeysToSiteKey.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1721361395971-AddNewTypeAndUpdatedUniqueKeysToSiteKey.ts deleted file mode 100644 index 6fdb4ea80b..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1721361395971-AddNewTypeAndUpdatedUniqueKeysToSiteKey.ts +++ /dev/null @@ -1,75 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddNewTypeAndUpdatedUniqueKeysToSiteKey1721361395971 - implements MigrationInterface -{ - name = 'AddNewTypeAndUpdatedUniqueKeysToSiteKey1721361395971'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `DROP INDEX "hmt"."IDX_271231e19f913b8a0cf028e9e7"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" DROP CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" DROP CONSTRAINT "site_keys_site_key_key"`, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."site_keys_type_enum" RENAME TO "site_keys_type_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."site_keys_type_enum" AS ENUM('hcaptcha', 'registration')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ALTER COLUMN "type" TYPE "hmt"."site_keys_type_enum" USING "type"::"text"::"hmt"."site_keys_type_enum"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."site_keys_type_enum_old"`); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" DROP CONSTRAINT "site_keys_user_id_key"`, - ); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_2dcfd04b329a0fd4be7f376512" ON "hmt"."site_keys" ("user_id") WHERE "type" = 'hcaptcha'`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ADD CONSTRAINT "UQ_7100e356f506f79d28eb2ba3e46" UNIQUE ("site_key", "type", "user_id")`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ADD CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `DROP INDEX "hmt"."IDX_2dcfd04b329a0fd4be7f376512"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" DROP CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" DROP CONSTRAINT "UQ_7100e356f506f79d28eb2ba3e46"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ADD CONSTRAINT "site_keys_user_id_key" UNIQUE ("user_id")`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."site_keys_type_enum_old" AS ENUM('fortune', 'cvat', 'hcaptcha')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ALTER COLUMN "type" TYPE "hmt"."site_keys_type_enum_old" USING "type"::"text"::"hmt"."site_keys_type_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."site_keys_type_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."site_keys_type_enum_old" RENAME TO "site_keys_type_enum"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ADD CONSTRAINT "site_keys_site_key_key" UNIQUE ("site_key")`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ADD CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_271231e19f913b8a0cf028e9e7" ON "hmt"."site_keys" ("site_key", "type") `, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1721994760450-nullableSiteKey.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1721994760450-nullableSiteKey.ts deleted file mode 100644 index 74469d5531..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1721994760450-nullableSiteKey.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class NullableSiteKey1721994760450 implements MigrationInterface { - name = 'NullableSiteKey1721994760450'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `DROP INDEX "hmt"."IDX_2dcfd04b329a0fd4be7f376512"`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_2dcfd04b329a0fd4be7f376512" ON "hmt"."site_keys" ("user_id") WHERE (type = 'hcaptcha'::hmt.site_keys_type_enum)`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1723476224900-migrateToVeriffStatuses.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1723476224900-migrateToVeriffStatuses.ts deleted file mode 100644 index d78cdea627..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1723476224900-migrateToVeriffStatuses.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class NewKycStatus1723476224900 implements MigrationInterface { - name = 'NewKycStatus1723476224900'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ADD "url" character varying NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ADD CONSTRAINT "UQ_bea0dcf47873917fc654b514f36" UNIQUE ("url")`, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."kycs_status_enum" RENAME TO "kycs_status_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."kycs_status_enum" AS ENUM('none', 'approved', 'resubmission_requested', 'declined', 'review', 'expired', 'abandoned', 'error')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" DROP DEFAULT`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" TYPE "hmt"."kycs_status_enum" USING "status"::"text"::"hmt"."kycs_status_enum"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" SET DEFAULT 'none'`, - ); - await queryRunner.query(`DROP TYPE "hmt"."kycs_status_enum_old"`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."kycs_status_enum_old" AS ENUM('NONE', 'APPROVED', 'SUBMISSION_REQUIRED', 'RESUBMISSION_REQUIRED', 'REJECTED', 'PENDING_VERIFICATION', 'RESET', 'ERROR')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" DROP DEFAULT`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" TYPE "hmt"."kycs_status_enum_old" USING "status"::"text"::"hmt"."kycs_status_enum_old"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" SET DEFAULT 'NONE'`, - ); - await queryRunner.query(`DROP TYPE "hmt"."kycs_status_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."kycs_status_enum_old" RENAME TO "kycs_status_enum"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" DROP CONSTRAINT "UQ_bea0dcf47873917fc654b514f36"`, - ); - await queryRunner.query(`ALTER TABLE "hmt"."kycs" DROP COLUMN "url"`); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1728727174601-UpdateWebhookEnumValuesToLowerCase.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1728727174601-UpdateWebhookEnumValuesToLowerCase.ts deleted file mode 100644 index 812cb4c847..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1728727174601-UpdateWebhookEnumValuesToLowerCase.ts +++ /dev/null @@ -1,399 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class UpdateWebhookEnumValuesToLowerCase1728727174601 - implements MigrationInterface -{ - name = 'UpdateWebhookEnumValuesToLowerCase1728727174601'; - - public async up(queryRunner: QueryRunner): Promise { - // Webhook incoming status enum - await queryRunner.query(` - ALTER TYPE "hmt"."webhook_incoming_status_enum" - RENAME TO "webhook_incoming_status_enum_old" - `); - - await queryRunner.query(` - CREATE TYPE "hmt"."webhook_incoming_status_enum" AS ENUM( - 'pending', 'completed', 'failed', 'paid' - ) - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."webhook_incoming" - ALTER COLUMN "status" TYPE TEXT USING "status"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."webhook_incoming" - SET "status" = LOWER("status") - WHERE "status" IN ('PENDING', 'COMPLETED', 'FAILED', 'PAID'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."webhook_incoming" - ALTER COLUMN "status" TYPE "hmt"."webhook_incoming_status_enum" USING "status"::"hmt"."webhook_incoming_status_enum"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."webhook_incoming_status_enum_old"; - `); - - // User role enum - await queryRunner.query(` - ALTER TYPE "hmt"."users_role_enum" - RENAME TO "users_role_enum_old" - `); - - await queryRunner.query(` - CREATE TYPE "hmt"."users_role_enum" AS ENUM( - 'operator', 'worker', 'human_app', 'admin' - ) - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."users" - ALTER COLUMN "role" TYPE TEXT USING "role"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."users" - SET "role" = LOWER("role") - WHERE "role" IN ('OPERATOR', 'WORKER', 'HUMAN_APP', 'ADMIN'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."users" - ALTER COLUMN "role" TYPE "hmt"."users_role_enum" USING "role"::"hmt"."users_role_enum"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."users_role_enum_old"; - `); - - // User status enum - await queryRunner.query(` - ALTER TYPE "hmt"."users_status_enum" - RENAME TO "users_status_enum_old" - `); - - await queryRunner.query(` - CREATE TYPE "hmt"."users_status_enum" AS ENUM( - 'active', 'inactive', 'pending' - ) - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."users" - ALTER COLUMN "status" TYPE TEXT USING "status"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."users" - SET "status" = LOWER("status") - WHERE "status" IN ('ACTIVE', 'INACTIVE', 'PENDING'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."users" - ALTER COLUMN "status" TYPE "hmt"."users_status_enum" USING "status"::"hmt"."users_status_enum"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."users_status_enum_old"; - `); - - // Creadential status enum - await queryRunner.query(` - ALTER TYPE "hmt"."credentials_status_enum" - RENAME TO "credentials_status_enum_old" - `); - - await queryRunner.query(` - CREATE TYPE "hmt"."credentials_status_enum" AS ENUM( - 'active', 'expired', 'validated', 'on_chain' - ) - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."credentials" - ALTER COLUMN "status" TYPE TEXT USING "status"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."credentials" - SET "status" = LOWER("status") - WHERE "status" IN ('ACTIVE', 'EXPIRED', 'VALIDATED', 'ON_CHAIN'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."credentials" - ALTER COLUMN "status" TYPE "hmt"."credentials_status_enum" USING "status"::"hmt"."credentials_status_enum"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."credentials_status_enum_old"; - `); - - // Creadential validation status enum - await queryRunner.query(` - ALTER TYPE "hmt"."credential_validations_status_enum" - RENAME TO "credential_validations_status_enum_old" - `); - - await queryRunner.query(` - CREATE TYPE "hmt"."credential_validations_status_enum" AS ENUM( - 'validated', 'on_chain' - ) - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."credential_validations" - ALTER COLUMN "status" TYPE TEXT USING "status"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."credential_validations" - SET "status" = LOWER("status") - WHERE "status" IN ('VALIDATED', 'ON_CHAIN'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."credential_validations" - ALTER COLUMN "status" TYPE "hmt"."credential_validations_status_enum" USING "status"::"hmt"."credential_validations_status_enum"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."credential_validations_status_enum_old"; - `); - - // Reputation type enum - await queryRunner.query(` - ALTER TYPE "hmt"."reputation_type_enum" - RENAME TO "reputation_type_enum_old" - `); - - await queryRunner.query(` - CREATE TYPE "hmt"."reputation_type_enum" AS ENUM( - 'worker', 'job_launcher', 'exchange_oracle', 'recording_oracle', - 'reputation_oracle', 'credential_validator' - ) - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."reputation" - ALTER COLUMN "type" TYPE TEXT USING "type"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."reputation" - SET "type" = LOWER("type") - WHERE "type" IN ('WORKER', 'JOB_LAUNCHER', 'EXCHANGE_ORACLE', - 'RECORDING_ORACLE', 'REPUTATION_ORACLE', 'CREDENTIAL_VALIDATOR'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."reputation" - ALTER COLUMN "type" TYPE "hmt"."reputation_type_enum" USING "type"::"hmt"."reputation_type_enum"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."reputation_type_enum_old"; - `); - } - - public async down(queryRunner: QueryRunner): Promise { - // Webhook incoming status enum - await queryRunner.query(` - CREATE TYPE "hmt"."webhook_incoming_status_enum_old" AS ENUM( - 'PENDING', 'COMPLETED', 'FAILED', 'PAID' - ); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."webhook_incoming" - ALTER COLUMN "status" TYPE TEXT USING "status"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."webhook_incoming" - SET "status" = UPPER("status") - WHERE "status" IN ('pending', 'completed', 'failed', 'paid'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."webhook_incoming" - ALTER COLUMN "status" TYPE "hmt"."webhook_incoming_status_enum_old" USING "status"::"hmt"."webhook_incoming_status_enum_old"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."webhook_incoming_status_enum"; - `); - - await queryRunner.query(` - ALTER TYPE "hmt"."webhook_incoming_status_enum_old" - RENAME TO "webhook_incoming_status_enum"; - `); - - // User role enum - await queryRunner.query(` - CREATE TYPE "hmt"."users_role_enum_old" AS ENUM( - 'OPERATOR', 'WORKER', 'HUMAN_APP', 'ADMIN' - ); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."users" - ALTER COLUMN "role" TYPE TEXT USING "role"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."users" - SET "role" = UPPER("role") - WHERE "role" IN ('operator', 'worker', 'human_app', 'admin'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."users" - ALTER COLUMN "role" TYPE "hmt"."users_role_enum_old" USING "role"::"hmt"."users_role_enum_old"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."users_role_enum"; - `); - - await queryRunner.query(` - ALTER TYPE "hmt"."users_role_enum_old" - RENAME TO "users_role_enum"; - `); - - // User status enum - await queryRunner.query(` - CREATE TYPE "hmt"."users_status_enum_old" AS ENUM( - 'ACTIVE', 'INACTIVE', 'PENDING' - ); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."users" - ALTER COLUMN "status" TYPE TEXT USING "status"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."users" - SET "status" = UPPER("status") - WHERE "status" IN ('active', 'inactive', 'pending'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."users" - ALTER COLUMN "status" TYPE "hmt"."users_status_enum_old" USING "status"::"hmt"."users_status_enum_old"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."users_status_enum"; - `); - - await queryRunner.query(` - ALTER TYPE "hmt"."users_status_enum_old" - RENAME TO "users_status_enum"; - `); - - // Creadential status enum - await queryRunner.query(` - CREATE TYPE "hmt"."credentials_status_enum_old" AS ENUM( - 'ACTIVE', 'EXPIRED', 'VALIDATED', 'ON_CHAIN' - ); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."credentials" - ALTER COLUMN "status" TYPE TEXT USING "status"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."credentials" - SET "status" = UPPER("status") - WHERE "status" IN ('active', 'expired', 'validated', 'on_chain'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."credentials" - ALTER COLUMN "status" TYPE "hmt"."credentials_status_enum_old" USING "status"::"hmt"."credentials_status_enum_old"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."credentials_status_enum"; - `); - - await queryRunner.query(` - ALTER TYPE "hmt"."credentials_status_enum_old" - RENAME TO "credentials_status_enum"; - `); - - // Creadential validation status enum - await queryRunner.query(` - CREATE TYPE "hmt"."credential_validations_status_enum_old" AS ENUM( - 'VALIDATED', 'ON_CHAIN' - ); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."credential_validations" - ALTER COLUMN "status" TYPE TEXT USING "status"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."credential_validations" - SET "status" = UPPER("status") - WHERE "status" IN ('validated', 'on_chain'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."credential_validations" - ALTER COLUMN "status" TYPE "hmt"."credential_validations_status_enum_old" USING "status"::"hmt"."credential_validations_status_enum_old"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."credential_validations_status_enum"; - `); - - await queryRunner.query(` - ALTER TYPE "hmt"."credential_validations_status_enum_old" - RENAME TO "credential_validations_status_enum"; - `); - - // Reputation type enum - await queryRunner.query(` - CREATE TYPE "hmt"."reputation_type_enum_old" AS ENUM( - 'WORKER', 'JOB_LAUNCHER', 'EXCHANGE_ORACLE', - 'RECORDING_ORACLE', 'REPUTATION_ORACLE', 'CREDENTIAL_VALIDATOR' - ); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."reputation" - ALTER COLUMN "type" TYPE TEXT USING "type"::TEXT; - `); - - await queryRunner.query(` - UPDATE "hmt"."reputation" - SET "type" = UPPER("type") - WHERE "type" IN ('worker', 'job_launcher', 'exchange_oracle', - 'recording_oracle', 'reputation_oracle', 'credential_validator'); - `); - - await queryRunner.query(` - ALTER TABLE "hmt"."reputation" - ALTER COLUMN "type" TYPE "hmt"."reputation_type_enum_old" USING "type"::"hmt"."reputation_type_enum_old"; - `); - - await queryRunner.query(` - DROP TYPE "hmt"."reputation_type_enum"; - `); - - await queryRunner.query(` - ALTER TYPE "hmt"."reputation_type_enum_old" - RENAME TO "reputation_type_enum"; - `); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1731562977435-AddWebhookOutgoingAndEscrowCompletionTrackingTables.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1731562977435-AddWebhookOutgoingAndEscrowCompletionTrackingTables.ts deleted file mode 100644 index 39aac01761..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1731562977435-AddWebhookOutgoingAndEscrowCompletionTrackingTables.ts +++ /dev/null @@ -1,99 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddWebhookOutgoingAndEscrowCompletionTrackingTables1731562977435 - implements MigrationInterface -{ - name = 'AddWebhookOutgoingAndEscrowCompletionTrackingTables1731562977435'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."webhook_incoming" DROP COLUMN "results_url"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."webhook_incoming" ADD COLUMN "failure_detail" varchar`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."webhook_outgoing_status_enum" AS ENUM('pending', 'sent', 'failed')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."webhook_outgoing" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "payload" jsonb NOT NULL, "hash" character varying NOT NULL, "url" character varying NOT NULL, "failure_detail" character varying, "retries_count" integer NOT NULL, "wait_until" TIMESTAMP WITH TIME ZONE NOT NULL, "status" "hmt"."webhook_outgoing_status_enum" NOT NULL, CONSTRAINT "PK_d232b33ccee326e251936e16c5f" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_d33daa25634fccb127ead889d4" ON "hmt"."webhook_outgoing" ("hash") `, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."escrow_completion_tracking_status_enum" AS ENUM('pending', 'paid', 'completed', 'failed')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."escrow_completion_tracking" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "chain_id" integer NOT NULL, "escrow_address" character varying NOT NULL, "final_results_url" character varying, "final_results_hash" character varying, "failure_detail" character varying, "retries_count" integer NOT NULL, "wait_until" TIMESTAMP WITH TIME ZONE NOT NULL, "status" "hmt"."escrow_completion_tracking_status_enum" NOT NULL, CONSTRAINT "PK_a6abebca3ce8e49155aaf14ccc8" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_146945054beb996cfe6edf1789" ON "hmt"."escrow_completion_tracking" ("escrow_address", "chain_id") `, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."webhook_incoming_status_enum" RENAME TO "webhook_incoming_status_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."webhook_incoming_status_enum" AS ENUM('pending', 'completed', 'failed')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."webhook_incoming" ALTER COLUMN "status" TYPE "hmt"."webhook_incoming_status_enum" USING "status"::"text"::"hmt"."webhook_incoming_status_enum"`, - ); - await queryRunner.query( - `DROP TYPE "hmt"."webhook_incoming_status_enum_old"`, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."cron-jobs_cron_job_type_enum" RENAME TO "cron-jobs_cron_job_type_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum" AS ENUM('process-pending-incoming-webhook', 'process-pending-outgoing-webhook', 'process-pending-escrow-completion-tracking', 'process-paid-escrow-completion-tracking')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."cron-jobs" ALTER COLUMN "cron_job_type" TYPE "hmt"."cron-jobs_cron_job_type_enum" USING "cron_job_type"::"text"::"hmt"."cron-jobs_cron_job_type_enum"`, - ); - await queryRunner.query( - `DROP TYPE "hmt"."cron-jobs_cron_job_type_enum_old"`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum_old" AS ENUM('process-pending-webhook', 'process-paid-webhook')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."cron-jobs" ALTER COLUMN "cron_job_type" TYPE "hmt"."cron-jobs_cron_job_type_enum_old" USING "cron_job_type"::"text"::"hmt"."cron-jobs_cron_job_type_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."cron-jobs_cron_job_type_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."cron-jobs_cron_job_type_enum_old" RENAME TO "cron-jobs_cron_job_type_enum"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."webhook_incoming_status_enum_old" AS ENUM('pending', 'completed', 'failed', 'paid')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."webhook_incoming" ALTER COLUMN "status" TYPE "hmt"."webhook_incoming_status_enum_old" USING "status"::"text"::"hmt"."webhook_incoming_status_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."webhook_incoming_status_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."webhook_incoming_status_enum_old" RENAME TO "webhook_incoming_status_enum"`, - ); - await queryRunner.query( - `DROP INDEX "hmt"."IDX_146945054beb996cfe6edf1789"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."escrow_completion_tracking"`); - await queryRunner.query( - `DROP TYPE "hmt"."escrow_completion_tracking_status_enum"`, - ); - await queryRunner.query( - `DROP INDEX "hmt"."IDX_d33daa25634fccb127ead889d4"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."webhook_outgoing"`); - await queryRunner.query(`DROP TYPE "hmt"."webhook_outgoing_status_enum"`); - await queryRunner.query( - `ALTER TABLE "hmt"."webhook_incoming" DROP COLUMN "failure_detail"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."webhook_incoming" ADD COLUMN "results_url" varchar`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1736357403602-escrowAwaitingPayouts.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1736357403602-escrowAwaitingPayouts.ts deleted file mode 100644 index bfdb332814..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1736357403602-escrowAwaitingPayouts.ts +++ /dev/null @@ -1,73 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class EscrowAwaitingPayouts1736357403602 implements MigrationInterface { - name = 'EscrowAwaitingPayouts1736357403602'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TABLE "hmt"."escrow_payouts_batch" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "escrow_completion_tracking_id" integer NOT NULL, "payouts" json NOT NULL, "payouts_hash" character varying NOT NULL, "tx_nonce" integer, CONSTRAINT "PK_6eb1d2e51d7c024fc681dfa67a7" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_44fd0222c43ed95845dd718f2a" ON "hmt"."escrow_payouts_batch" ("escrow_completion_tracking_id", "payouts_hash") `, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."escrow_completion_tracking_status_enum" RENAME TO "escrow_completion_tracking_status_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."escrow_completion_tracking_status_enum" AS ENUM('pending', 'awaiting_payouts', 'paid', 'completed', 'failed')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."escrow_completion_tracking" ALTER COLUMN "status" TYPE "hmt"."escrow_completion_tracking_status_enum" USING "status"::"text"::"hmt"."escrow_completion_tracking_status_enum"`, - ); - await queryRunner.query( - `DROP TYPE "hmt"."escrow_completion_tracking_status_enum_old"`, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."cron-jobs_cron_job_type_enum" RENAME TO "cron-jobs_cron_job_type_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum" AS ENUM('process-pending-incoming-webhook', 'process-pending-outgoing-webhook', 'process-pending-escrow-completion-tracking', 'process-paid-escrow-completion-tracking', 'process-awaiting-escrow-payouts')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."cron-jobs" ALTER COLUMN "cron_job_type" TYPE "hmt"."cron-jobs_cron_job_type_enum" USING "cron_job_type"::"text"::"hmt"."cron-jobs_cron_job_type_enum"`, - ); - await queryRunner.query( - `DROP TYPE "hmt"."cron-jobs_cron_job_type_enum_old"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."escrow_payouts_batch" ADD CONSTRAINT "FK_e0c93d91e0edd3becc3c84ed0a0" FOREIGN KEY ("escrow_completion_tracking_id") REFERENCES "hmt"."escrow_completion_tracking"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."escrow_payouts_batch" DROP CONSTRAINT "FK_e0c93d91e0edd3becc3c84ed0a0"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum_old" AS ENUM('process-pending-incoming-webhook', 'process-pending-outgoing-webhook', 'process-pending-escrow-completion-tracking', 'process-paid-escrow-completion-tracking')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."cron-jobs" ALTER COLUMN "cron_job_type" TYPE "hmt"."cron-jobs_cron_job_type_enum_old" USING "cron_job_type"::"text"::"hmt"."cron-jobs_cron_job_type_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."cron-jobs_cron_job_type_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."cron-jobs_cron_job_type_enum_old" RENAME TO "cron-jobs_cron_job_type_enum"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."escrow_completion_tracking_status_enum_old" AS ENUM('pending', 'paid', 'completed', 'failed')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."escrow_completion_tracking" ALTER COLUMN "status" TYPE "hmt"."escrow_completion_tracking_status_enum_old" USING "status"::"text"::"hmt"."escrow_completion_tracking_status_enum_old"`, - ); - await queryRunner.query( - `DROP TYPE "hmt"."escrow_completion_tracking_status_enum"`, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."escrow_completion_tracking_status_enum_old" RENAME TO "escrow_completion_tracking_status_enum"`, - ); - await queryRunner.query( - `DROP INDEX "hmt"."IDX_44fd0222c43ed95845dd718f2a"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."escrow_payouts_batch"`); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1738163861072-deleteCredentials.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1738163861072-deleteCredentials.ts deleted file mode 100644 index 367a491108..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1738163861072-deleteCredentials.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class DeleteCredentials1738163861072 implements MigrationInterface { - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."credential_validations" DROP CONSTRAINT "FK_d1896792b36ed073631703df40a"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."credential_validations" DROP CONSTRAINT "FK_a546350ec2c97f067c802ff672a"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."reputation_type_enum_old" AS ENUM('worker', 'job_launcher', 'exchange_oracle', 'recording_oracle', 'reputation_oracle')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."reputation" ALTER COLUMN "type" TYPE "hmt"."reputation_type_enum_old" USING "type"::"text"::"hmt"."reputation_type_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."reputation_type_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."reputation_type_enum_old" RENAME TO "reputation_type_enum"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."credential_validations"`); - await queryRunner.query( - `DROP TYPE "hmt"."credential_validations_status_enum"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."credentials"`); - await queryRunner.query(`DROP TYPE "hmt"."credentials_status_enum"`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."credentials_status_enum" AS ENUM('active', 'expired', 'validated', 'on_chain')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."credentials" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "reference" character varying NOT NULL, "description" text NOT NULL, "url" character varying NOT NULL, "status" "hmt"."credentials_status_enum" NOT NULL, "starts_at" TIMESTAMP WITH TIME ZONE NOT NULL, "expires_at" TIMESTAMP WITH TIME ZONE, CONSTRAINT "UQ_481aa1ff346d6eee7656880c568" UNIQUE ("reference"), CONSTRAINT "PK_1e38bc43be6697cdda548ad27a6" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."credential_validations_status_enum" AS ENUM('validated', 'on_chain')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."credential_validations" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "status" "hmt"."credential_validations_status_enum" NOT NULL, "certificate" character varying, "credential_id" integer, "user_id" integer, CONSTRAINT "PK_ea03b6fbdfcddca7c2625f6a091" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."reputation_type_enum" RENAME TO "reputation_type_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."reputation_type_enum" AS ENUM('worker', 'job_launcher', 'exchange_oracle', 'recording_oracle', 'reputation_oracle', 'credential_validator')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."reputation" ALTER COLUMN "type" TYPE "hmt"."reputation_type_enum" USING "type"::"text"::"hmt"."reputation_type_enum"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."reputation_type_enum_old"`); - await queryRunner.query( - `ALTER TABLE "hmt"."credential_validations" ADD CONSTRAINT "FK_a546350ec2c97f067c802ff672a" FOREIGN KEY ("credential_id") REFERENCES "hmt"."credentials"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."credential_validations" ADD CONSTRAINT "FK_d1896792b36ed073631703df40a" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1740657822938-addNDA.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1740657822938-addNDA.ts deleted file mode 100644 index f013edba35..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1740657822938-addNDA.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddNDA1740657822938 implements MigrationInterface { - name = 'AddNDA1740657822938'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."users" ADD "nda_signed_url" character varying`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."users" DROP COLUMN "nda_signed_url"`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1741695024694-removeRedundantKYCStatus.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1741695024694-removeRedundantKYCStatus.ts deleted file mode 100644 index dd87bc548c..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1741695024694-removeRedundantKYCStatus.ts +++ /dev/null @@ -1,45 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class RemoveRedundantKYCStatus1741695024694 - implements MigrationInterface -{ - name = 'RemoveRedundantKYCStatus1741695024694'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TYPE "hmt"."kycs_status_enum" RENAME TO "kycs_status_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."kycs_status_enum" AS ENUM('none', 'approved', 'resubmission_requested', 'declined', 'review', 'expired', 'abandoned')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" DROP DEFAULT`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" TYPE "hmt"."kycs_status_enum" USING "status"::"text"::"hmt"."kycs_status_enum"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" SET DEFAULT 'none'`, - ); - await queryRunner.query(`DROP TYPE "hmt"."kycs_status_enum_old"`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."kycs_status_enum_old" AS ENUM('none', 'approved', 'resubmission_requested', 'declined', 'review', 'expired', 'abandoned', 'error')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" DROP DEFAULT`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" TYPE "hmt"."kycs_status_enum_old" USING "status"::"text"::"hmt"."kycs_status_enum_old"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ALTER COLUMN "status" SET DEFAULT 'none'`, - ); - await queryRunner.query(`DROP TYPE "hmt"."kycs_status_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."kycs_status_enum_old" RENAME TO "kycs_status_enum"`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1741875593626-fixSitekeyUserRef.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1741875593626-fixSitekeyUserRef.ts deleted file mode 100644 index c572734b0b..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1741875593626-fixSitekeyUserRef.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class FixSitekeyUserRef1741875593626 implements MigrationInterface { - name = 'FixSitekeyUserRef1741875593626'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ALTER COLUMN "user_id" SET NOT NULL`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ALTER COLUMN "user_id" DROP NOT NULL`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1742377717756-updateTokenEntity.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1742377717756-updateTokenEntity.ts deleted file mode 100644 index 2f1fdc1c36..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1742377717756-updateTokenEntity.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class UpdateTokenEntity1742377717756 implements MigrationInterface { - name = 'UpdateTokenEntity1742377717756'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `DROP INDEX "hmt"."IDX_306030d9411d291750fd115857"`, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."tokens_type_enum" RENAME TO "tokens_type_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."tokens_type_enum" AS ENUM('email', 'password', 'refresh')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" ALTER COLUMN "type" TYPE "hmt"."tokens_type_enum" USING "type"::"text"::"hmt"."tokens_type_enum"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."tokens_type_enum_old"`); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_306030d9411d291750fd115857" ON "hmt"."tokens" ("type", "user_id") `, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `DROP INDEX "hmt"."IDX_306030d9411d291750fd115857"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."tokens_type_enum_old" AS ENUM('EMAIL', 'PASSWORD', 'REFRESH')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" ALTER COLUMN "type" TYPE "hmt"."tokens_type_enum_old" USING "type"::"text"::"hmt"."tokens_type_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."tokens_type_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."tokens_type_enum_old" RENAME TO "tokens_type_enum"`, - ); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_306030d9411d291750fd115857" ON "hmt"."tokens" ("type", "user_id") `, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1742462400299-addAbuse.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1742462400299-addAbuse.ts deleted file mode 100644 index 0642cc46d1..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1742462400299-addAbuse.ts +++ /dev/null @@ -1,57 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddAbuse1742462400299 implements MigrationInterface { - name = 'AddAbuse1742462400299'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."abuses_status_enum" AS ENUM('pending', 'completed', 'failed', 'notified')`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."abuses_decision_enum" AS ENUM('rejected', 'accepted')`, - ); - await queryRunner.query( - `CREATE TABLE "hmt"."abuses" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "chain_id" integer NOT NULL, "escrow_address" character varying NOT NULL, "status" "hmt"."abuses_status_enum" NOT NULL, "decision" "hmt"."abuses_decision_enum", "amount" numeric(30,18), "user_id" integer NOT NULL, "retries_count" integer NOT NULL, "wait_until" TIMESTAMP WITH TIME ZONE NOT NULL, CONSTRAINT "PK_8cfbf5b6d26e83e4fd5955c8c8b" PRIMARY KEY ("id"))`, - ); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_023d33d90733aa64f612995657" ON "hmt"."abuses" ("chain_id", "escrow_address") `, - ); - await queryRunner.query( - `ALTER TYPE "hmt"."cron-jobs_cron_job_type_enum" RENAME TO "cron-jobs_cron_job_type_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum" AS ENUM('process-pending-incoming-webhook', 'process-pending-outgoing-webhook', 'process-pending-escrow-completion-tracking', 'process-paid-escrow-completion-tracking', 'process-awaiting-escrow-payouts', 'process-requested-abuse', 'process-classified-abuse')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."cron-jobs" ALTER COLUMN "cron_job_type" TYPE "hmt"."cron-jobs_cron_job_type_enum" USING "cron_job_type"::"text"::"hmt"."cron-jobs_cron_job_type_enum"`, - ); - await queryRunner.query( - `DROP TYPE "hmt"."cron-jobs_cron_job_type_enum_old"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."abuses" ADD CONSTRAINT "FK_8136cf4f4cef59bdb54d17c714d" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."abuses" DROP CONSTRAINT "FK_8136cf4f4cef59bdb54d17c714d"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum_old" AS ENUM('process-pending-incoming-webhook', 'process-pending-outgoing-webhook', 'process-pending-escrow-completion-tracking', 'process-paid-escrow-completion-tracking', 'process-awaiting-escrow-payouts')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."cron-jobs" ALTER COLUMN "cron_job_type" TYPE "hmt"."cron-jobs_cron_job_type_enum_old" USING "cron_job_type"::"text"::"hmt"."cron-jobs_cron_job_type_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."cron-jobs_cron_job_type_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."cron-jobs_cron_job_type_enum_old" RENAME TO "cron-jobs_cron_job_type_enum"`, - ); - await queryRunner.query( - `DROP INDEX "hmt"."IDX_023d33d90733aa64f612995657"`, - ); - await queryRunner.query(`DROP TABLE "hmt"."abuses"`); - await queryRunner.query(`DROP TYPE "hmt"."abuses_decision_enum"`); - await queryRunner.query(`DROP TYPE "hmt"."abuses_status_enum"`); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1744201451282-qualificationAdjustments.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1744201451282-qualificationAdjustments.ts deleted file mode 100644 index 303a5793fc..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1744201451282-qualificationAdjustments.ts +++ /dev/null @@ -1,91 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class QualificationAdjustments1744201451282 - implements MigrationInterface -{ - name = 'QualificationAdjustments1744201451282'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_bfa80c2767c180533958bf9c971"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ALTER COLUMN "user_id" SET NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ALTER COLUMN "qualification_id" SET NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" DROP COLUMN "title"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" ADD "title" character varying(50) NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" DROP COLUMN "description"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" ADD "description" character varying(200) NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" DROP COLUMN "expires_at"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" ADD "expires_at" TIMESTAMP WITH TIME ZONE`, - ); - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_f40f66a6ba16b27a81ec48f566" ON "hmt"."user_qualifications" ("user_id", "qualification_id") `, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_bfa80c2767c180533958bf9c971" FOREIGN KEY ("qualification_id") REFERENCES "hmt"."qualifications"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_bfa80c2767c180533958bf9c971"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5"`, - ); - await queryRunner.query( - `DROP INDEX "hmt"."IDX_f40f66a6ba16b27a81ec48f566"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" DROP COLUMN "expires_at"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" ADD "expires_at" TIMESTAMP`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" DROP COLUMN "description"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" ADD "description" text NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" DROP COLUMN "title"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."qualifications" ADD "title" text NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ALTER COLUMN "qualification_id" DROP NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ALTER COLUMN "user_id" DROP NOT NULL`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_bfa80c2767c180533958bf9c971" FOREIGN KEY ("qualification_id") REFERENCES "hmt"."qualifications"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1744732021099-UniqueReputations.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1744732021099-UniqueReputations.ts deleted file mode 100644 index 29dca04ffa..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1744732021099-UniqueReputations.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class UniqueReputations1744732021099 implements MigrationInterface { - name = 'UniqueReputations1744732021099'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE UNIQUE INDEX "IDX_5012dff596f037415a1370a0cb" ON "hmt"."reputation" ("chain_id", "address", "type") `, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `DROP INDEX "hmt"."IDX_5012dff596f037415a1370a0cb"`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1747219638888-cascadeDeletion.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1747219638888-cascadeDeletion.ts deleted file mode 100644 index b652d84bda..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1747219638888-cascadeDeletion.ts +++ /dev/null @@ -1,83 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class CascadeDeletion1747219638888 implements MigrationInterface { - name = 'CascadeDeletion1747219638888'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" DROP CONSTRAINT "FK_8769073e38c365f315426554ca5"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" DROP CONSTRAINT "FK_bbfe1fa864841e82cff1be09e8b"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_bfa80c2767c180533958bf9c971"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."abuses" DROP CONSTRAINT "FK_8136cf4f4cef59bdb54d17c714d"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" DROP CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" ADD CONSTRAINT "FK_8769073e38c365f315426554ca5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ADD CONSTRAINT "FK_bbfe1fa864841e82cff1be09e8b" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_bfa80c2767c180533958bf9c971" FOREIGN KEY ("qualification_id") REFERENCES "hmt"."qualifications"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."abuses" ADD CONSTRAINT "FK_8136cf4f4cef59bdb54d17c714d" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ADD CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" DROP CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."abuses" DROP CONSTRAINT "FK_8136cf4f4cef59bdb54d17c714d"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_bfa80c2767c180533958bf9c971"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" DROP CONSTRAINT "FK_bbfe1fa864841e82cff1be09e8b"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" DROP CONSTRAINT "FK_8769073e38c365f315426554ca5"`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."site_keys" ADD CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."abuses" ADD CONSTRAINT "FK_8136cf4f4cef59bdb54d17c714d" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_bfa80c2767c180533958bf9c971" FOREIGN KEY ("qualification_id") REFERENCES "hmt"."qualifications"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."kycs" ADD CONSTRAINT "FK_bbfe1fa864841e82cff1be09e8b" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."tokens" ADD CONSTRAINT "FK_8769073e38c365f315426554ca5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1747228037203-RemoveHumanAppRole.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1747228037203-RemoveHumanAppRole.ts deleted file mode 100644 index 44c63d4368..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1747228037203-RemoveHumanAppRole.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class RemoveHumanAppRole1747228037203 implements MigrationInterface { - name = 'RemoveHumanAppRole1747228037203'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TYPE "hmt"."users_role_enum" RENAME TO "users_role_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."users_role_enum" AS ENUM('operator', 'worker', 'admin')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ALTER COLUMN "role" TYPE "hmt"."users_role_enum" USING "role"::"text"::"hmt"."users_role_enum"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."users_role_enum_old"`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."users_role_enum_old" AS ENUM('operator', 'worker', 'human_app', 'admin')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."users" ALTER COLUMN "role" TYPE "hmt"."users_role_enum_old" USING "role"::"text"::"hmt"."users_role_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."users_role_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."users_role_enum_old" RENAME TO "users_role_enum"`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1747301407259-AddDbTtlCronJob.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1747301407259-AddDbTtlCronJob.ts deleted file mode 100644 index 520c0a2bf1..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1747301407259-AddDbTtlCronJob.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddDbTtlCronJob1747301407259 implements MigrationInterface { - name = 'AddDbTtlCronJob1747301407259'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TYPE "hmt"."cron-jobs_cron_job_type_enum" RENAME TO "cron-jobs_cron_job_type_enum_old"`, - ); - await queryRunner.query( - `CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum" AS ENUM('process-pending-incoming-webhook', 'process-pending-outgoing-webhook', 'process-pending-escrow-completion-tracking', 'process-paid-escrow-completion-tracking', 'process-awaiting-escrow-payouts', 'process-requested-abuse', 'process-classified-abuse', 'delete-expired-database-records')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."cron-jobs" ALTER COLUMN "cron_job_type" TYPE "hmt"."cron-jobs_cron_job_type_enum" USING "cron_job_type"::"text"::"hmt"."cron-jobs_cron_job_type_enum"`, - ); - await queryRunner.query( - `DROP TYPE "hmt"."cron-jobs_cron_job_type_enum_old"`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum_old" AS ENUM('process-pending-incoming-webhook', 'process-pending-outgoing-webhook', 'process-pending-escrow-completion-tracking', 'process-paid-escrow-completion-tracking', 'process-awaiting-escrow-payouts', 'process-requested-abuse', 'process-classified-abuse')`, - ); - await queryRunner.query( - `ALTER TABLE "hmt"."cron-jobs" ALTER COLUMN "cron_job_type" TYPE "hmt"."cron-jobs_cron_job_type_enum_old" USING "cron_job_type"::"text"::"hmt"."cron-jobs_cron_job_type_enum_old"`, - ); - await queryRunner.query(`DROP TYPE "hmt"."cron-jobs_cron_job_type_enum"`); - await queryRunner.query( - `ALTER TYPE "hmt"."cron-jobs_cron_job_type_enum_old" RENAME TO "cron-jobs_cron_job_type_enum"`, - ); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1750766313641-AddReasonToAbuse.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1750766313641-AddReasonToAbuse.ts deleted file mode 100644 index bbc84f71cd..0000000000 --- a/packages/apps/reputation-oracle/server/src/database/migrations/1750766313641-AddReasonToAbuse.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { MigrationInterface, QueryRunner } from 'typeorm'; - -export class AddReasonToAbuse1750766313641 implements MigrationInterface { - name = 'AddReasonToAbuse1750766313641'; - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query( - `ALTER TABLE "hmt"."abuses" ADD "reason" text NOT NULL`, - ); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE "hmt"."abuses" DROP COLUMN "reason"`); - } -} diff --git a/packages/apps/reputation-oracle/server/src/database/migrations/1752590727473-InitialMigration.ts b/packages/apps/reputation-oracle/server/src/database/migrations/1752590727473-InitialMigration.ts new file mode 100644 index 0000000000..f38cfa461f --- /dev/null +++ b/packages/apps/reputation-oracle/server/src/database/migrations/1752590727473-InitialMigration.ts @@ -0,0 +1,218 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; +import { DATABASE_SCHEMA_NAME } from '../../common/constants'; + +export class InitialMigration1752590727473 implements MigrationInterface { + name = 'InitialMigration1752590727473'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.createSchema(DATABASE_SCHEMA_NAME, true); + await queryRunner.query( + `CREATE TYPE "hmt"."reputation_type_enum" AS ENUM('worker', 'job_launcher', 'exchange_oracle', 'recording_oracle', 'reputation_oracle')`, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."reputation" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "chain_id" integer NOT NULL, "address" character varying NOT NULL, "type" "hmt"."reputation_type_enum" NOT NULL, "reputation_points" integer NOT NULL, CONSTRAINT "PK_640807583e8622e1d9bbe6f1b7b" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE UNIQUE INDEX "IDX_5012dff596f037415a1370a0cb" ON "hmt"."reputation" ("chain_id", "address", "type") `, + ); + await queryRunner.query( + `CREATE TYPE "hmt"."tokens_type_enum" AS ENUM('email', 'password', 'refresh')`, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."tokens" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "uuid" uuid NOT NULL DEFAULT uuid_generate_v4(), "type" "hmt"."tokens_type_enum" NOT NULL, "expires_at" TIMESTAMP WITH TIME ZONE NOT NULL, "user_id" integer NOT NULL, CONSTRAINT "UQ_57b0dd7af7c6a0b7d4c3fd5c464" UNIQUE ("uuid"), CONSTRAINT "PK_3001e89ada36263dabf1fb6210a" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE UNIQUE INDEX "IDX_306030d9411d291750fd115857" ON "hmt"."tokens" ("type", "user_id") `, + ); + await queryRunner.query( + `CREATE TYPE "hmt"."users_role_enum" AS ENUM('operator', 'worker', 'admin')`, + ); + await queryRunner.query( + `CREATE TYPE "hmt"."users_status_enum" AS ENUM('active', 'pending', 'inactive')`, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."users" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "password" character varying, "email" character varying, "role" "hmt"."users_role_enum" NOT NULL, "evm_address" character varying, "nonce" character varying, "status" "hmt"."users_status_enum" NOT NULL, "nda_signed_url" character varying, CONSTRAINT "UQ_97672ac88f789774dd47f7c8be3" UNIQUE ("email"), CONSTRAINT "UQ_6009c050ae797d7e13ba0b0759b" UNIQUE ("evm_address"), CONSTRAINT "PK_a3ffb1c0c8416b9fc6f907b7433" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TYPE "hmt"."kycs_status_enum" AS ENUM('none', 'approved', 'resubmission_requested', 'declined', 'review', 'expired', 'abandoned')`, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."kycs" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "session_id" character varying NOT NULL, "status" "hmt"."kycs_status_enum" NOT NULL DEFAULT 'none', "country" character varying, "message" character varying, "user_id" integer NOT NULL, "url" character varying NOT NULL, CONSTRAINT "UQ_76ea5d4f1a010a5fe4949771f4c" UNIQUE ("session_id"), CONSTRAINT "UQ_bea0dcf47873917fc654b514f36" UNIQUE ("url"), CONSTRAINT "REL_bbfe1fa864841e82cff1be09e8" UNIQUE ("user_id"), CONSTRAINT "PK_6f4a4d2b94576014ab3d5e77694" PRIMARY KEY ("id", "session_id"))`, + ); + await queryRunner.query( + `CREATE TYPE "hmt"."cron-jobs_cron_job_type_enum" AS ENUM('process-pending-incoming-webhook', 'process-pending-outgoing-webhook', 'process-pending-escrow-completion-tracking', 'process-paid-escrow-completion-tracking', 'process-awaiting-escrow-payouts', 'process-requested-abuse', 'process-classified-abuse', 'delete-expired-database-records')`, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."cron-jobs" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "cron_job_type" "hmt"."cron-jobs_cron_job_type_enum" NOT NULL, "started_at" TIMESTAMP WITH TIME ZONE NOT NULL, "completed_at" TIMESTAMP WITH TIME ZONE, CONSTRAINT "PK_268498ac0d3e7472960fb0faeb1" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE UNIQUE INDEX "IDX_0dafd70b737e71d21490ad0126" ON "hmt"."cron-jobs" ("cron_job_type") `, + ); + await queryRunner.query( + `CREATE TYPE "hmt"."site_keys_type_enum" AS ENUM('hcaptcha', 'registration')`, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."site_keys" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "site_key" character varying NOT NULL, "type" "hmt"."site_keys_type_enum" NOT NULL, "user_id" integer NOT NULL, CONSTRAINT "UQ_7100e356f506f79d28eb2ba3e46" UNIQUE ("site_key", "type", "user_id"), CONSTRAINT "PK_bae12fca8759496669088974738" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."qualifications" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "reference" character varying NOT NULL, "title" character varying(50) NOT NULL, "description" character varying(200) NOT NULL, "expires_at" TIMESTAMP WITH TIME ZONE, CONSTRAINT "UQ_f9c59623bb945337cd22c538d2b" UNIQUE ("reference"), CONSTRAINT "PK_9ed4d526ac3b76ba3f1c1080433" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE UNIQUE INDEX "IDX_f9c59623bb945337cd22c538d2" ON "hmt"."qualifications" ("reference") `, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."user_qualifications" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "user_id" integer NOT NULL, "qualification_id" integer NOT NULL, CONSTRAINT "PK_4b567ea1379253b4edbec543a08" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE UNIQUE INDEX "IDX_f40f66a6ba16b27a81ec48f566" ON "hmt"."user_qualifications" ("user_id", "qualification_id") `, + ); + await queryRunner.query( + `CREATE TYPE "hmt"."webhook_incoming_status_enum" AS ENUM('pending', 'completed', 'failed')`, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."webhook_incoming" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "chain_id" integer NOT NULL, "escrow_address" character varying NOT NULL, "failure_detail" character varying, "retries_count" integer NOT NULL, "wait_until" TIMESTAMP WITH TIME ZONE NOT NULL, "status" "hmt"."webhook_incoming_status_enum" NOT NULL, CONSTRAINT "PK_08e16abccb4720323203bf8f7a0" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE UNIQUE INDEX "IDX_ed1eb73afbf214f9bd4c2d03f4" ON "hmt"."webhook_incoming" ("chain_id", "escrow_address") `, + ); + await queryRunner.query( + `CREATE TYPE "hmt"."escrow_completion_tracking_status_enum" AS ENUM('pending', 'awaiting_payouts', 'paid', 'completed', 'failed')`, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."escrow_completion_tracking" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "chain_id" integer NOT NULL, "escrow_address" character varying NOT NULL, "final_results_url" character varying, "final_results_hash" character varying, "failure_detail" character varying, "retries_count" integer NOT NULL, "wait_until" TIMESTAMP WITH TIME ZONE NOT NULL, "status" "hmt"."escrow_completion_tracking_status_enum" NOT NULL, CONSTRAINT "PK_a6abebca3ce8e49155aaf14ccc8" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE UNIQUE INDEX "IDX_146945054beb996cfe6edf1789" ON "hmt"."escrow_completion_tracking" ("escrow_address", "chain_id") `, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."escrow_payouts_batch" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "escrow_completion_tracking_id" integer NOT NULL, "payouts" json NOT NULL, "payouts_hash" character varying NOT NULL, "tx_nonce" integer, CONSTRAINT "PK_6eb1d2e51d7c024fc681dfa67a7" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE UNIQUE INDEX "IDX_44fd0222c43ed95845dd718f2a" ON "hmt"."escrow_payouts_batch" ("escrow_completion_tracking_id", "payouts_hash") `, + ); + await queryRunner.query( + `CREATE TYPE "hmt"."abuses_status_enum" AS ENUM('pending', 'completed', 'failed', 'notified')`, + ); + await queryRunner.query( + `CREATE TYPE "hmt"."abuses_decision_enum" AS ENUM('rejected', 'accepted')`, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."abuses" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "chain_id" integer NOT NULL, "escrow_address" character varying NOT NULL, "status" "hmt"."abuses_status_enum" NOT NULL, "decision" "hmt"."abuses_decision_enum", "amount" numeric(30,18), "reason" text NOT NULL, "user_id" integer NOT NULL, "retries_count" integer NOT NULL, "wait_until" TIMESTAMP WITH TIME ZONE NOT NULL, CONSTRAINT "PK_8cfbf5b6d26e83e4fd5955c8c8b" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE UNIQUE INDEX "IDX_023d33d90733aa64f612995657" ON "hmt"."abuses" ("chain_id", "escrow_address") `, + ); + await queryRunner.query( + `CREATE TYPE "hmt"."webhook_outgoing_status_enum" AS ENUM('pending', 'sent', 'failed')`, + ); + await queryRunner.query( + `CREATE TABLE "hmt"."webhook_outgoing" ("id" SERIAL NOT NULL, "created_at" TIMESTAMP WITH TIME ZONE NOT NULL, "updated_at" TIMESTAMP WITH TIME ZONE NOT NULL, "payload" jsonb NOT NULL, "hash" character varying NOT NULL, "url" character varying NOT NULL, "failure_detail" character varying, "retries_count" integer NOT NULL, "wait_until" TIMESTAMP WITH TIME ZONE NOT NULL, "status" "hmt"."webhook_outgoing_status_enum" NOT NULL, CONSTRAINT "PK_d232b33ccee326e251936e16c5f" PRIMARY KEY ("id"))`, + ); + await queryRunner.query( + `CREATE UNIQUE INDEX "IDX_d33daa25634fccb127ead889d4" ON "hmt"."webhook_outgoing" ("hash") `, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."tokens" ADD CONSTRAINT "FK_8769073e38c365f315426554ca5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."kycs" ADD CONSTRAINT "FK_bbfe1fa864841e82cff1be09e8b" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."site_keys" ADD CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."user_qualifications" ADD CONSTRAINT "FK_bfa80c2767c180533958bf9c971" FOREIGN KEY ("qualification_id") REFERENCES "hmt"."qualifications"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."escrow_payouts_batch" ADD CONSTRAINT "FK_e0c93d91e0edd3becc3c84ed0a0" FOREIGN KEY ("escrow_completion_tracking_id") REFERENCES "hmt"."escrow_completion_tracking"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."abuses" ADD CONSTRAINT "FK_8136cf4f4cef59bdb54d17c714d" FOREIGN KEY ("user_id") REFERENCES "hmt"."users"("id") ON DELETE CASCADE ON UPDATE NO ACTION`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "hmt"."abuses" DROP CONSTRAINT "FK_8136cf4f4cef59bdb54d17c714d"`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."escrow_payouts_batch" DROP CONSTRAINT "FK_e0c93d91e0edd3becc3c84ed0a0"`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_bfa80c2767c180533958bf9c971"`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."user_qualifications" DROP CONSTRAINT "FK_6b49cc36c9a6ed1f393840709d5"`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."site_keys" DROP CONSTRAINT "FK_266dc68bd3412cb17b5d927b30c"`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."kycs" DROP CONSTRAINT "FK_bbfe1fa864841e82cff1be09e8b"`, + ); + await queryRunner.query( + `ALTER TABLE "hmt"."tokens" DROP CONSTRAINT "FK_8769073e38c365f315426554ca5"`, + ); + await queryRunner.query( + `DROP INDEX "hmt"."IDX_d33daa25634fccb127ead889d4"`, + ); + await queryRunner.query(`DROP TABLE "hmt"."webhook_outgoing"`); + await queryRunner.query(`DROP TYPE "hmt"."webhook_outgoing_status_enum"`); + await queryRunner.query( + `DROP INDEX "hmt"."IDX_023d33d90733aa64f612995657"`, + ); + await queryRunner.query(`DROP TABLE "hmt"."abuses"`); + await queryRunner.query(`DROP TYPE "hmt"."abuses_decision_enum"`); + await queryRunner.query(`DROP TYPE "hmt"."abuses_status_enum"`); + await queryRunner.query( + `DROP INDEX "hmt"."IDX_44fd0222c43ed95845dd718f2a"`, + ); + await queryRunner.query(`DROP TABLE "hmt"."escrow_payouts_batch"`); + await queryRunner.query( + `DROP INDEX "hmt"."IDX_146945054beb996cfe6edf1789"`, + ); + await queryRunner.query(`DROP TABLE "hmt"."escrow_completion_tracking"`); + await queryRunner.query( + `DROP TYPE "hmt"."escrow_completion_tracking_status_enum"`, + ); + await queryRunner.query( + `DROP INDEX "hmt"."IDX_ed1eb73afbf214f9bd4c2d03f4"`, + ); + await queryRunner.query(`DROP TABLE "hmt"."webhook_incoming"`); + await queryRunner.query(`DROP TYPE "hmt"."webhook_incoming_status_enum"`); + await queryRunner.query( + `DROP INDEX "hmt"."IDX_f40f66a6ba16b27a81ec48f566"`, + ); + await queryRunner.query(`DROP TABLE "hmt"."user_qualifications"`); + await queryRunner.query( + `DROP INDEX "hmt"."IDX_f9c59623bb945337cd22c538d2"`, + ); + await queryRunner.query(`DROP TABLE "hmt"."qualifications"`); + await queryRunner.query(`DROP TABLE "hmt"."site_keys"`); + await queryRunner.query(`DROP TYPE "hmt"."site_keys_type_enum"`); + await queryRunner.query( + `DROP INDEX "hmt"."IDX_0dafd70b737e71d21490ad0126"`, + ); + await queryRunner.query(`DROP TABLE "hmt"."cron-jobs"`); + await queryRunner.query(`DROP TYPE "hmt"."cron-jobs_cron_job_type_enum"`); + await queryRunner.query(`DROP TABLE "hmt"."kycs"`); + await queryRunner.query(`DROP TYPE "hmt"."kycs_status_enum"`); + await queryRunner.query(`DROP TABLE "hmt"."users"`); + await queryRunner.query(`DROP TYPE "hmt"."users_status_enum"`); + await queryRunner.query(`DROP TYPE "hmt"."users_role_enum"`); + await queryRunner.query( + `DROP INDEX "hmt"."IDX_306030d9411d291750fd115857"`, + ); + await queryRunner.query(`DROP TABLE "hmt"."tokens"`); + await queryRunner.query(`DROP TYPE "hmt"."tokens_type_enum"`); + await queryRunner.query( + `DROP INDEX "hmt"."IDX_5012dff596f037415a1370a0cb"`, + ); + await queryRunner.query(`DROP TABLE "hmt"."reputation"`); + await queryRunner.query(`DROP TYPE "hmt"."reputation_type_enum"`); + await queryRunner.dropSchema(DATABASE_SCHEMA_NAME); + } +}