Skip to content

Commit

Permalink
Replaced manual migrations with automatic one
Browse files Browse the repository at this point in the history
  • Loading branch information
aminlatifi committed Aug 20, 2024
1 parent 4aa771c commit 38fc395
Showing 5 changed files with 102 additions and 115 deletions.
55 changes: 55 additions & 0 deletions docker-compose-local-postgres-redis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
version: '3.3'

services:
impact-graph-postgres:
# Use this postgres image https://github.com/Giveth/postgres-givethio
image: ghcr.io/giveth/postgres-givethio:latest
restart: always
environment:
- POSTGRES_DB=givethio
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- PGDATA=/var/lib/postgresql/data/pgdata
ports:
- "5442:5432"
volumes:
- db-data:/var/lib/postgresql/data

impact-graph-postgres-test:
# CAUTION: Running tests will delete all records of this db, so just use this container for test
# For running application use above container port: 5442

# Use this postgres image https://github.com/Giveth/postgres-givethio
image: ghcr.io/giveth/postgres-givethio:latest
restart: always
environment:
- POSTGRES_DB=givethio
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
- PGDATA=/var/lib/postgresql/data/pgdata
ports:
- "5443:5432"
volumes:
- db-data-test:/var/lib/postgresql/data

redis-giveth:
# it's better to not using the latest tag, maybe latest tag have some breaking changes
image: redis:7.2.0-alpine3.18
container_name: redis-giveth
environment:
- REDIS_ALLOW_EMPTY_PASSWORD=yes
restart: always
ports:
- "6379:6379"
volumes:
- redis-data:/data

volumes:
db-data:
db-data-test:
redis-data:

networks:
giveth:
external: true

52 changes: 0 additions & 52 deletions migration/1724112704036-AddEmailConfirmationFieldsToUserTable.ts

This file was deleted.

63 changes: 0 additions & 63 deletions migration/1724112826669-CreateUserEmailVerificationTable.ts

This file was deleted.

45 changes: 45 additions & 0 deletions migration/1724143752405-EmailVerification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

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

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "user_email_verification" ("id" SERIAL NOT NULL, "userId" integer NOT NULL, "emailVerificationCode" text, "emailVerificationCodeExpiredAt" TIMESTAMP WITH TIME ZONE, CONSTRAINT "PK_8ad3e54beb79f46d33950e9d487" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`ALTER TABLE "user" ADD "emailConfirmed" boolean NOT NULL DEFAULT false`,
);
await queryRunner.query(
`ALTER TABLE "user" ADD "emailConfirmationSent" boolean NOT NULL DEFAULT false`,
);
await queryRunner.query(
`ALTER TABLE "user" ADD "emailConfirmationSentAt" TIMESTAMP WITH TIME ZONE`,
);
await queryRunner.query(
`ALTER TABLE "user" ADD "emailConfirmedAt" TIMESTAMP WITH TIME ZONE`,
);
await queryRunner.query(
`ALTER TABLE "project" ADD "teaser" character varying`,
);
await queryRunner.query(`ALTER TABLE "project" ADD "teamMembers" jsonb`);
await queryRunner.query(`ALTER TABLE "project" ADD "abc" jsonb`);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "project" DROP COLUMN "abc"`);
await queryRunner.query(`ALTER TABLE "project" DROP COLUMN "teamMembers"`);
await queryRunner.query(`ALTER TABLE "project" DROP COLUMN "teaser"`);
await queryRunner.query(
`ALTER TABLE "user" DROP COLUMN "emailConfirmedAt"`,
);
await queryRunner.query(
`ALTER TABLE "user" DROP COLUMN "emailConfirmationSentAt"`,
);
await queryRunner.query(
`ALTER TABLE "user" DROP COLUMN "emailConfirmationSent"`,
);
await queryRunner.query(`ALTER TABLE "user" DROP COLUMN "emailConfirmed"`);
await queryRunner.query(`DROP TABLE "user_email_verification"`);
}
}
2 changes: 2 additions & 0 deletions src/entities/project.ts
Original file line number Diff line number Diff line change
@@ -153,6 +153,8 @@ export class Abc {

@Entity()
@ObjectType()
@Index('trgm_idx_project_title', { synchronize: false })
@Index('trgm_idx_project_description', { synchronize: false })
export class Project extends BaseEntity {
@Field(_type => ID)
@PrimaryGeneratedColumn()

0 comments on commit 38fc395

Please sign in to comment.