Skip to content

Commit

Permalink
Comment migrations related to endaoment (#1706)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadranjbarz authored Jul 21, 2024
1 parent 93e80b0 commit c7223db
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@ export class AddFieldToCategoryToCanUseOnFrontend1721377038761
ALTER TABLE "category"
ADD COLUMN "canUseOnFrontend" boolean DEFAULT true;
`);

await queryRunner.query(`
UPDATE "category"
SET "canUseOnFrontend" = false
WHERE "value" = 'Endaoment';
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { ORGANIZATION_LABELS } from '../src/entities/organization';
import { NETWORK_IDS } from '../src/provider';
import { ORGANIZATION_LABELS } from '../../src/entities/organization';
import { NETWORK_IDS } from '../../src/provider';

export class AddEndaomentOrganization1719740230650
implements MigrationInterface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,6 @@ export class CreateEndaomentsCategories1719808494903
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
// Create Main Categories
// await queryRunner.query(`
// INSERT INTO "main_category" ("title", "slug", "description", "banner", "isActive")
// VALUES
// ('NGO', 'ngo', 'Non-Governmental Organizations', '', true),
// ('Art & Culture', 'art-culture', 'Art and Cultural activities', '', true),
// ('Health & Wellness', 'health-wellness', 'Health and Wellness initiatives', '', true),
// ('Finance', 'finance', 'Financial Services and Initiatives', '', true);
// `);

// await queryRunner.query(`
// INSERT INTO "main_category" ("title", "slug", "description", "banner", "isActive")
// VALUES
// ('Art & Culture', 'art-culture', 'Art and Cultural activities', '', true)
// `);

// Retrieve Main Category IDs
const ngoMainCategory = await queryRunner.query(
`SELECT "id" FROM "main_category" WHERE "slug" = 'ngo' LIMIT 1`,
Expand All @@ -37,7 +21,7 @@ export class CreateEndaomentsCategories1719808494903
// Create Sub-Categories
await queryRunner.query(`
INSERT INTO "category" ("name", "value", "source", "mainCategoryId", "isActive")
VALUES
VALUES
('Endaoment', 'endaoment', '', ${ngoMainCategory[0].id}, true),
('Religious', 'religious', '', ${artCultureMainCategory[0].id}, true),
('Disaster Relief', 'disaster-relief', '', ${ngoMainCategory[0].id}, true),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { endaomentProjects } from './data/importedEndaomentProjects';
import { NETWORK_IDS } from '../src/provider';
import { ReviewStatus } from '../src/entities/project';
import { endaomentProjectCategoryMapping } from './data/endaomentProjectCategoryMapping';
import { endaomentProjectCategoryMapping } from '../data/endaomentProjectCategoryMapping';
import { endaomentProjects } from '../data/importedEndaomentProjects';
import { NETWORK_IDS } from '../../src/provider';
import { ReviewStatus } from '../../src/entities/project';

export class AddEndaomentsProjects1719808494904 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
// Insert the Endaoment organization if it doesn't exist
await queryRunner.query(`
INSERT INTO "organization" ("name", "disableNotifications", "disableRecurringDonations", "disableUpdateEnforcement", "label", "website", "supportCustomTokens")
VALUES ('Endaoment', false, false, false, 'endaoment', NULL, false)
ON CONFLICT DO NOTHING;
`);

// Get the organization ID for Endaoment
Expand All @@ -33,7 +32,7 @@ export class AddEndaomentsProjects1719808494904 implements MigrationInterface {
// eslint-disable-next-line no-console
console.log('User is not in our DB, creating .... ');
await queryRunner.query(`
INSERT INTO public.user ("walletAddress", role,"loginType", name)
INSERT INTO public.user ("walletAddress", role,"loginType", name)
VALUES('${endaomentAdminWalletAddress.toLowerCase()}', 'restricted','wallet', 'Endaoment Admin');
`);
adminUser = (
Expand Down Expand Up @@ -78,7 +77,7 @@ export class AddEndaomentsProjects1719808494904 implements MigrationInterface {
${adminUser?.id}
)
ON CONFLICT ("slug") DO NOTHING; -- Handle conflict on unique constraint
`);

// Get the inserted project's ID
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { ORGANIZATION_LABELS } from '../src/entities/organization';
import { ORGANIZATION_LABELS } from '../../src/entities/organization';

export class FillDescriptionSummaryToEndaomentProjects1721286322530
implements MigrationInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { ORGANIZATION_LABELS } from '../src/entities/organization';
import { ORGANIZATION_LABELS } from '../../src/entities/organization';

export class RemoveSpecialCharactersFromEndaomentProjectsSlug1721290930117
implements MigrationInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
import { endaomentProjectCategoryMapping } from './data/endaomentProjectCategoryMapping';
import { endaomentProjects } from './data/importedEndaomentProjects';
import { endaomentProjectCategoryMapping } from '../data/endaomentProjectCategoryMapping';
import { endaomentProjects } from '../data/importedEndaomentProjects';

export class ModifyEndaomentCategories1721300929435
implements MigrationInterface
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddCanUseOnFrontendToEndaomentProjects1721448501422
implements MigrationInterface
{
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
UPDATE "category"
SET "canUseOnFrontend" = false
WHERE "value" = 'Endaoment';
`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`
UPDATE "category"
SET "canUseOnFrontend" = true
WHERE "value" = 'Endaoment';
`);
}
}

0 comments on commit c7223db

Please sign in to comment.