Skip to content
Merged
15 changes: 15 additions & 0 deletions migration/1746613421847-addRankToProject.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddRankToProject1746613421847 implements MigrationInterface {
name = 'AddRankToProject1746613421847';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "project" ADD "rank" real DEFAULT '0'`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "project" DROP COLUMN "rank"`);
}
}
61 changes: 61 additions & 0 deletions migration/1746613421848-populateProjectRanks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class PopulateProjectRanks1746613421848 implements MigrationInterface {
name = 'PopulateProjectRanks1746613421848';

public async up(queryRunner: QueryRunner): Promise<void> {
// Define the project ticker to rank mapping
const projectRanks = [
{ ticker: 'PACK', rank: 1 },
{ ticker: 'X23', rank: 1 },
{ ticker: 'TDM', rank: 1 },
{ ticker: 'PRSM', rank: 1 },
{ ticker: 'CTZN', rank: 1 },
{ ticker: 'H2DAO', rank: 2 },
{ ticker: 'LOCK', rank: 2 },
{ ticker: 'ACHAD', rank: 2 },
{ ticker: 'GRNDT', rank: 2 },
{ ticker: 'AKA', rank: 3 },
{ ticker: 'BEAST', rank: 3 },
{ ticker: 'MELS', rank: 3 },
];

// Update each project's rank based on ticker
for (const { ticker, rank } of projectRanks) {
await queryRunner.query(
`UPDATE "project"
SET "rank" = $1
WHERE "abc"->>'tokenTicker' = $2`,
[rank, ticker],
);
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
// Define the project tickers that were updated
const projectTickers = [
'PACK',
'X23',
'TDM',
'PRSM',
'CTZN',
'H2DAO',
'LOCK',
'ACHAD',
'GRNDT',
'AKA',
'BEAST',
'MELS',
];

// Reset rank to default (0) for these projects
for (const ticker of projectTickers) {
await queryRunner.query(
`UPDATE "project"
SET "rank" = 0
WHERE "abc"->>'tokenTicker' = $1`,
[ticker],
);
}
}
}
21 changes: 21 additions & 0 deletions migration/1746613421849-addReelVideoToProjectSocialMediaType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class AddReelVideoToProjectSocialMediaType1746613421849
implements MigrationInterface
{
name = 'AddReelVideoToProjectSocialMediaType1746613421849';

public async up(queryRunner: QueryRunner): Promise<void> {
// Add REEL_VIDEO to the project_social_media_type_enum
await queryRunner.query(
`ALTER TYPE "public"."project_social_media_type_enum" ADD VALUE 'REEL_VIDEO'`,
);
}

public async down(_queryRunner: QueryRunner): Promise<void> {
// Note: PostgreSQL doesn't support removing enum values directly
// This would require recreating the enum type and updating all references
// For safety, we'll leave the enum value in place during rollback
// If rollback is absolutely necessary, it would need to be done manually
}
}
104 changes: 104 additions & 0 deletions migration/1746613421850-populateProjectReelVideos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class PopulateProjectReelVideos1746613421850
implements MigrationInterface
{
name = 'PopulateProjectReelVideos1746613421850';

public async up(queryRunner: QueryRunner): Promise<void> {
// Define the project ticker to Reel Video URL mapping
const projectReelVideos = [
{
ticker: 'PACK',
url: 'https://youtube.com/shorts/8Gk-Ly8Foac?feature=share',
},
{
ticker: 'X23',
url: 'https://youtube.com/shorts/AnKtMfnQrmU?feature=share',
},
{
ticker: 'TDM',
url: 'https://youtube.com/shorts/ZZX6NuXkJO8?feature=share',
},
{
ticker: 'PRSM',
url: 'https://youtube.com/shorts/k5qXJH-o2Z0?feature=share',
},
{
ticker: 'CTZN',
url: 'https://youtube.com/shorts/neF1zbCeImU?feature=share',
},
{
ticker: 'H2DAO',
url: 'https://youtube.com/shorts/Zgd30u7ta-A?feature=share',
},
{
ticker: 'LOCK',
url: 'https://youtube.com/shorts/WLeG91LzzVc?feature=share',
},
{
ticker: 'ACHAD',
url: 'https://youtube.com/shorts/G0-PXR7V-ro?feature=share',
},
{
ticker: 'BEAST',
url: 'https://youtube.com/shorts/Ouq2984E5F4?feature=share',
},
{
ticker: 'MELS',
url: 'https://youtube.com/shorts/KTXsNhANaDs?feature=share',
},
];

// Insert Reel Video social media entries for each project
for (const { ticker, url } of projectReelVideos) {
// First, get the project ID and admin user ID for the project with this ticker
const projectResult = await queryRunner.query(
`SELECT id, "adminUserId"
FROM "project"
WHERE "abc"->>'tokenTicker' = $1`,
[ticker],
);

if (projectResult.length > 0) {
const projectId = projectResult[0].id;
const adminUserId = projectResult[0].adminUserId;

// Insert the Reel Video social media entry
await queryRunner.query(
`INSERT INTO "project_social_media" ("type", "link", "projectId", "userId")
VALUES ('REEL_VIDEO', $1, $2, $3)`,
[url, projectId, adminUserId],
);
}
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
// Define the project tickers that were updated
const projectTickers = [
'PACK',
'X23',
'TDM',
'PRSM',
'CTZN',
'H2DAO',
'LOCK',
'ACHAD',
'BEAST',
'MELS',
];

// Remove Reel Video social media entries for these projects
for (const ticker of projectTickers) {
await queryRunner.query(
`DELETE FROM "project_social_media"
WHERE "type" = 'REEL_VIDEO'
AND "projectId" IN (
SELECT id FROM "project" WHERE "abc"->>'tokenTicker' = $1
)`,
[ticker],
);
}
}
}
26 changes: 26 additions & 0 deletions migration/1746613421852-createVestingScheduleTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class CreateVestingScheduleTable1746613421852
implements MigrationInterface
{
name = 'CreateVestingScheduleTable1746613421852';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "vesting_schedule" (
"id" SERIAL NOT NULL,
"name" character varying NOT NULL,
"start" TIMESTAMP NOT NULL,
"cliff" TIMESTAMP NOT NULL,
"end" TIMESTAMP NOT NULL,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(),
CONSTRAINT "PK_vesting_schedule_id" PRIMARY KEY ("id")
)`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP TABLE "vesting_schedule"`);
}
}
71 changes: 71 additions & 0 deletions migration/1746613421853-populateVestingSchedules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class PopulateVestingSchedules1746613421853
implements MigrationInterface
{
name = 'PopulateVestingSchedules1746613421853';

public async up(queryRunner: QueryRunner): Promise<void> {
// Define the vesting schedule data
const vestingSchedules = [
{
name: 'Season 1 projects',
start: '2024-10-29',
cliff: '2025-10-29',
end: '2026-10-29',
},
{
name: 'Season 2 projects',
start: '2025-04-11',
cliff: '2026-04-11',
end: '2027-04-11',
},
{
name: 'R1 Season 1 buyers',
start: '2024-12-20',
cliff: '2025-06-20',
end: '2025-12-20',
},
{
name: 'R2 Season 1 buyers',
start: '2025-05-13',
cliff: '2025-10-13',
end: '2026-03-13',
},
{
name: 'R2 Season 2 buyers',
start: '2025-05-13',
cliff: '2025-11-13',
end: '2026-05-13',
},
];

// Insert each vesting schedule
for (const schedule of vestingSchedules) {
await queryRunner.query(
`INSERT INTO "vesting_schedule" ("name", "start", "cliff", "end")
VALUES ($1, $2, $3, $4)`,
[schedule.name, schedule.start, schedule.cliff, schedule.end],
);
}
}

public async down(queryRunner: QueryRunner): Promise<void> {
// Define the schedule names that were inserted
const scheduleNames = [
'Season 1 projects',
'Season 2 projects',
'R1 Season 1 buyers',
'R2 Season 1 buyers',
'R2 Season 2 buyers',
];

// Remove the inserted vesting schedules
for (const name of scheduleNames) {
await queryRunner.query(
`DELETE FROM "vesting_schedule" WHERE "name" = $1`,
[name],
);
}
}
}
28 changes: 28 additions & 0 deletions migration/1746613421854-createTokenHolderTable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

export class CreateTokenHolderTable1746613421854 implements MigrationInterface {
name = 'CreateTokenHolderTable1746613421854';

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "token_holder" (
"id" SERIAL NOT NULL,
"projectName" character varying NOT NULL,
"address" character varying NOT NULL,
"tag" character varying,
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(),
CONSTRAINT "PK_token_holder_id" PRIMARY KEY ("id")
)`,
);

await queryRunner.query(
`CREATE INDEX "IDX_token_holder_address" ON "token_holder" ("address")`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`DROP INDEX "IDX_token_holder_address"`);
await queryRunner.query(`DROP TABLE "token_holder"`);
}
}
Loading
Loading