Skip to content

Commit a1521f8

Browse files
authored
Merge pull request #222 from GeneralMagicio/addNewTablesAndFields
Add new tables and fields
2 parents d3dcdd4 + 6313ad4 commit a1521f8

24 files changed

+1341
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class AddRankToProject1746613421847 implements MigrationInterface {
4+
name = 'AddRankToProject1746613421847';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`ALTER TABLE "project" ADD "rank" real DEFAULT '0'`,
9+
);
10+
}
11+
12+
public async down(queryRunner: QueryRunner): Promise<void> {
13+
await queryRunner.query(`ALTER TABLE "project" DROP COLUMN "rank"`);
14+
}
15+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class PopulateProjectRanks1746613421848 implements MigrationInterface {
4+
name = 'PopulateProjectRanks1746613421848';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
// Define the project ticker to rank mapping
8+
const projectRanks = [
9+
{ ticker: 'PACK', rank: 1 },
10+
{ ticker: 'X23', rank: 1 },
11+
{ ticker: 'TDM', rank: 1 },
12+
{ ticker: 'PRSM', rank: 1 },
13+
{ ticker: 'CTZN', rank: 1 },
14+
{ ticker: 'H2DAO', rank: 2 },
15+
{ ticker: 'LOCK', rank: 2 },
16+
{ ticker: 'ACHAD', rank: 2 },
17+
{ ticker: 'GRNDT', rank: 2 },
18+
{ ticker: 'AKA', rank: 3 },
19+
{ ticker: 'BEAST', rank: 3 },
20+
{ ticker: 'MELS', rank: 3 },
21+
];
22+
23+
// Update each project's rank based on ticker
24+
for (const { ticker, rank } of projectRanks) {
25+
await queryRunner.query(
26+
`UPDATE "project"
27+
SET "rank" = $1
28+
WHERE "abc"->>'tokenTicker' = $2`,
29+
[rank, ticker],
30+
);
31+
}
32+
}
33+
34+
public async down(queryRunner: QueryRunner): Promise<void> {
35+
// Define the project tickers that were updated
36+
const projectTickers = [
37+
'PACK',
38+
'X23',
39+
'TDM',
40+
'PRSM',
41+
'CTZN',
42+
'H2DAO',
43+
'LOCK',
44+
'ACHAD',
45+
'GRNDT',
46+
'AKA',
47+
'BEAST',
48+
'MELS',
49+
];
50+
51+
// Reset rank to default (0) for these projects
52+
for (const ticker of projectTickers) {
53+
await queryRunner.query(
54+
`UPDATE "project"
55+
SET "rank" = 0
56+
WHERE "abc"->>'tokenTicker' = $1`,
57+
[ticker],
58+
);
59+
}
60+
}
61+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class AddReelVideoToProjectSocialMediaType1746613421849
4+
implements MigrationInterface
5+
{
6+
name = 'AddReelVideoToProjectSocialMediaType1746613421849';
7+
8+
public async up(queryRunner: QueryRunner): Promise<void> {
9+
// Add REEL_VIDEO to the project_social_media_type_enum
10+
await queryRunner.query(
11+
`ALTER TYPE "public"."project_social_media_type_enum" ADD VALUE 'REEL_VIDEO'`,
12+
);
13+
}
14+
15+
public async down(_queryRunner: QueryRunner): Promise<void> {
16+
// Note: PostgreSQL doesn't support removing enum values directly
17+
// This would require recreating the enum type and updating all references
18+
// For safety, we'll leave the enum value in place during rollback
19+
// If rollback is absolutely necessary, it would need to be done manually
20+
}
21+
}
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class PopulateProjectReelVideos1746613421850
4+
implements MigrationInterface
5+
{
6+
name = 'PopulateProjectReelVideos1746613421850';
7+
8+
public async up(queryRunner: QueryRunner): Promise<void> {
9+
// Define the project ticker to Reel Video URL mapping
10+
const projectReelVideos = [
11+
{
12+
ticker: 'PACK',
13+
url: 'https://youtube.com/shorts/8Gk-Ly8Foac?feature=share',
14+
},
15+
{
16+
ticker: 'X23',
17+
url: 'https://youtube.com/shorts/AnKtMfnQrmU?feature=share',
18+
},
19+
{
20+
ticker: 'TDM',
21+
url: 'https://youtube.com/shorts/ZZX6NuXkJO8?feature=share',
22+
},
23+
{
24+
ticker: 'PRSM',
25+
url: 'https://youtube.com/shorts/k5qXJH-o2Z0?feature=share',
26+
},
27+
{
28+
ticker: 'CTZN',
29+
url: 'https://youtube.com/shorts/neF1zbCeImU?feature=share',
30+
},
31+
{
32+
ticker: 'H2DAO',
33+
url: 'https://youtube.com/shorts/Zgd30u7ta-A?feature=share',
34+
},
35+
{
36+
ticker: 'LOCK',
37+
url: 'https://youtube.com/shorts/WLeG91LzzVc?feature=share',
38+
},
39+
{
40+
ticker: 'ACHAD',
41+
url: 'https://youtube.com/shorts/G0-PXR7V-ro?feature=share',
42+
},
43+
{
44+
ticker: 'BEAST',
45+
url: 'https://youtube.com/shorts/Ouq2984E5F4?feature=share',
46+
},
47+
{
48+
ticker: 'MELS',
49+
url: 'https://youtube.com/shorts/KTXsNhANaDs?feature=share',
50+
},
51+
];
52+
53+
// Insert Reel Video social media entries for each project
54+
for (const { ticker, url } of projectReelVideos) {
55+
// First, get the project ID and admin user ID for the project with this ticker
56+
const projectResult = await queryRunner.query(
57+
`SELECT id, "adminUserId"
58+
FROM "project"
59+
WHERE "abc"->>'tokenTicker' = $1`,
60+
[ticker],
61+
);
62+
63+
if (projectResult.length > 0) {
64+
const projectId = projectResult[0].id;
65+
const adminUserId = projectResult[0].adminUserId;
66+
67+
// Insert the Reel Video social media entry
68+
await queryRunner.query(
69+
`INSERT INTO "project_social_media" ("type", "link", "projectId", "userId")
70+
VALUES ('REEL_VIDEO', $1, $2, $3)`,
71+
[url, projectId, adminUserId],
72+
);
73+
}
74+
}
75+
}
76+
77+
public async down(queryRunner: QueryRunner): Promise<void> {
78+
// Define the project tickers that were updated
79+
const projectTickers = [
80+
'PACK',
81+
'X23',
82+
'TDM',
83+
'PRSM',
84+
'CTZN',
85+
'H2DAO',
86+
'LOCK',
87+
'ACHAD',
88+
'BEAST',
89+
'MELS',
90+
];
91+
92+
// Remove Reel Video social media entries for these projects
93+
for (const ticker of projectTickers) {
94+
await queryRunner.query(
95+
`DELETE FROM "project_social_media"
96+
WHERE "type" = 'REEL_VIDEO'
97+
AND "projectId" IN (
98+
SELECT id FROM "project" WHERE "abc"->>'tokenTicker' = $1
99+
)`,
100+
[ticker],
101+
);
102+
}
103+
}
104+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class CreateVestingScheduleTable1746613421852
4+
implements MigrationInterface
5+
{
6+
name = 'CreateVestingScheduleTable1746613421852';
7+
8+
public async up(queryRunner: QueryRunner): Promise<void> {
9+
await queryRunner.query(
10+
`CREATE TABLE "vesting_schedule" (
11+
"id" SERIAL NOT NULL,
12+
"name" character varying NOT NULL,
13+
"start" TIMESTAMP NOT NULL,
14+
"cliff" TIMESTAMP NOT NULL,
15+
"end" TIMESTAMP NOT NULL,
16+
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
17+
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(),
18+
CONSTRAINT "PK_vesting_schedule_id" PRIMARY KEY ("id")
19+
)`,
20+
);
21+
}
22+
23+
public async down(queryRunner: QueryRunner): Promise<void> {
24+
await queryRunner.query(`DROP TABLE "vesting_schedule"`);
25+
}
26+
}
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class PopulateVestingSchedules1746613421853
4+
implements MigrationInterface
5+
{
6+
name = 'PopulateVestingSchedules1746613421853';
7+
8+
public async up(queryRunner: QueryRunner): Promise<void> {
9+
// Define the vesting schedule data
10+
const vestingSchedules = [
11+
{
12+
name: 'Season 1 projects',
13+
start: '2024-10-29',
14+
cliff: '2025-10-29',
15+
end: '2026-10-29',
16+
},
17+
{
18+
name: 'Season 2 projects',
19+
start: '2025-04-11',
20+
cliff: '2026-04-11',
21+
end: '2027-04-11',
22+
},
23+
{
24+
name: 'R1 Season 1 buyers',
25+
start: '2024-12-20',
26+
cliff: '2025-06-20',
27+
end: '2025-12-20',
28+
},
29+
{
30+
name: 'R2 Season 1 buyers',
31+
start: '2025-05-13',
32+
cliff: '2025-10-13',
33+
end: '2026-03-13',
34+
},
35+
{
36+
name: 'R2 Season 2 buyers',
37+
start: '2025-05-13',
38+
cliff: '2025-11-13',
39+
end: '2026-05-13',
40+
},
41+
];
42+
43+
// Insert each vesting schedule
44+
for (const schedule of vestingSchedules) {
45+
await queryRunner.query(
46+
`INSERT INTO "vesting_schedule" ("name", "start", "cliff", "end")
47+
VALUES ($1, $2, $3, $4)`,
48+
[schedule.name, schedule.start, schedule.cliff, schedule.end],
49+
);
50+
}
51+
}
52+
53+
public async down(queryRunner: QueryRunner): Promise<void> {
54+
// Define the schedule names that were inserted
55+
const scheduleNames = [
56+
'Season 1 projects',
57+
'Season 2 projects',
58+
'R1 Season 1 buyers',
59+
'R2 Season 1 buyers',
60+
'R2 Season 2 buyers',
61+
];
62+
63+
// Remove the inserted vesting schedules
64+
for (const name of scheduleNames) {
65+
await queryRunner.query(
66+
`DELETE FROM "vesting_schedule" WHERE "name" = $1`,
67+
[name],
68+
);
69+
}
70+
}
71+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class CreateTokenHolderTable1746613421854 implements MigrationInterface {
4+
name = 'CreateTokenHolderTable1746613421854';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`CREATE TABLE "token_holder" (
9+
"id" SERIAL NOT NULL,
10+
"projectName" character varying NOT NULL,
11+
"address" character varying NOT NULL,
12+
"tag" character varying,
13+
"createdAt" TIMESTAMP NOT NULL DEFAULT now(),
14+
"updatedAt" TIMESTAMP NOT NULL DEFAULT now(),
15+
CONSTRAINT "PK_token_holder_id" PRIMARY KEY ("id")
16+
)`,
17+
);
18+
19+
await queryRunner.query(
20+
`CREATE INDEX "IDX_token_holder_address" ON "token_holder" ("address")`,
21+
);
22+
}
23+
24+
public async down(queryRunner: QueryRunner): Promise<void> {
25+
await queryRunner.query(`DROP INDEX "IDX_token_holder_address"`);
26+
await queryRunner.query(`DROP TABLE "token_holder"`);
27+
}
28+
}

0 commit comments

Comments
 (0)