Skip to content

Commit

Permalink
pre deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
radekm2000 committed Mar 24, 2024
1 parent 66c3d40 commit d6de60a
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/ecommerce/public/_redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* /index.html 200
113 changes: 113 additions & 0 deletions server/ecommerce/db/migrations/1711285970930-NewMigration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import { MigrationInterface, QueryRunner } from 'typeorm';

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

public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`CREATE TABLE "admin_notifications" ("id" SERIAL NOT NULL, "username" character varying NOT NULL, "userId" integer NOT NULL, "action" character varying NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), CONSTRAINT "PK_1fecd1cab747b7ab6e850091901" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "image" ("id" SERIAL NOT NULL, "imageUrl" character varying, "imageName" character varying NOT NULL, "productId" integer, CONSTRAINT "PK_d6db1ab4ee9ad9dbe86c64e4cc3" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "product" ("id" SERIAL NOT NULL, "brand" character varying NOT NULL, "category" character varying NOT NULL, "title" character varying NOT NULL, "description" character varying NOT NULL, "price" integer NOT NULL, "userId" integer, CONSTRAINT "PK_bebc9158e480b949565b4dc7a82" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "profile" ("id" SERIAL NOT NULL, "aboutYou" character varying, "country" character varying NOT NULL DEFAULT 'Poland', CONSTRAINT "PK_3dd8bfc97e4a77c70971591bdcb" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "follow" ("id" SERIAL NOT NULL, "followerId" integer, "followingId" integer, CONSTRAINT "PK_fda88bc28a84d2d6d06e19df6e5" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "message" ("id" SERIAL NOT NULL, "content" character varying NOT NULL, "conversationId" integer, "authorId" integer, CONSTRAINT "PK_ba01f0a3e0123651915008bc578" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "avatar" ("id" SERIAL NOT NULL, "avatarUrl" character varying, "avatarName" character varying NOT NULL, "userId" integer, CONSTRAINT "PK_50e36da9d45349941038eaf149d" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "review" ("id" SERIAL NOT NULL, "comment" character varying NOT NULL, "rating" integer NOT NULL, "createdAt" TIMESTAMP NOT NULL DEFAULT now(), "reviewRecipientId" integer, "reviewCreatorId" integer, CONSTRAINT "PK_2e4299a343a81574217255c00ca" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "user" ("id" SERIAL NOT NULL, "username" character varying NOT NULL, "googleId" character varying, "email" character varying NOT NULL, "password" character varying, "role" character varying NOT NULL DEFAULT 'user', "avatar" character varying, "profileId" integer, "avatarEntityId" integer, CONSTRAINT "UQ_78a916df40e02a9deb1c4b75edb" UNIQUE ("username"), CONSTRAINT "REL_9466682df91534dd95e4dbaa61" UNIQUE ("profileId"), CONSTRAINT "REL_b8bf2e21095af67654559d2fed" UNIQUE ("avatarEntityId"), CONSTRAINT "PK_cace4a159ff9f2512dd42373760" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "conversation" ("id" SERIAL NOT NULL, "lastMessageSentAt" TIMESTAMP NOT NULL DEFAULT now(), "creatorId" integer, "recipientId" integer, "lastMessageSentId" integer, CONSTRAINT "REL_941c7b5b184899308341512638" UNIQUE ("lastMessageSentId"), CONSTRAINT "PK_864528ec4274360a40f66c29845" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "notification" ("id" SERIAL NOT NULL, "isRead" boolean NOT NULL, "date" TIMESTAMP NOT NULL DEFAULT now(), "senderId" integer, "receiverId" integer, CONSTRAINT "PK_705b6c7cdf9b2c2ff7ac7872cb7" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`CREATE TABLE "product_notification" ("id" SERIAL NOT NULL, "message" character varying NOT NULL, "isRead" boolean NOT NULL, "receiverId" integer NOT NULL, "productId" integer, CONSTRAINT "PK_17eabbfd538c6ab61d0fa6425e0" PRIMARY KEY ("id"))`,
);
await queryRunner.query(
`ALTER TABLE "product" ADD CONSTRAINT "FK_329b8ae12068b23da547d3b4798" FOREIGN KEY ("userId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "follow" ADD CONSTRAINT "FK_550dce89df9570f251b6af2665a" FOREIGN KEY ("followerId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "follow" ADD CONSTRAINT "FK_e9f68503556c5d72a161ce38513" FOREIGN KEY ("followingId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "message" ADD CONSTRAINT "FK_c72d82fa0e8699a141ed6cc41b3" FOREIGN KEY ("authorId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "review" ADD CONSTRAINT "FK_30909ac2f5b587d9944fb7cf3ef" FOREIGN KEY ("reviewRecipientId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "review" ADD CONSTRAINT "FK_b9d6f5a7e9a73348c3dbf005d80" FOREIGN KEY ("reviewCreatorId") REFERENCES "user"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "user" ADD CONSTRAINT "FK_9466682df91534dd95e4dbaa616" FOREIGN KEY ("profileId") REFERENCES "profile"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "user" ADD CONSTRAINT "FK_b8bf2e21095af67654559d2fed2" FOREIGN KEY ("avatarEntityId") REFERENCES "avatar"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
await queryRunner.query(
`ALTER TABLE "conversation" ADD CONSTRAINT "FK_941c7b5b184899308341512638a" FOREIGN KEY ("lastMessageSentId") REFERENCES "message"("id") ON DELETE NO ACTION ON UPDATE NO ACTION`,
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(
`ALTER TABLE "conversation" DROP CONSTRAINT "FK_941c7b5b184899308341512638a"`,
);
await queryRunner.query(
`ALTER TABLE "user" DROP CONSTRAINT "FK_b8bf2e21095af67654559d2fed2"`,
);
await queryRunner.query(
`ALTER TABLE "user" DROP CONSTRAINT "FK_9466682df91534dd95e4dbaa616"`,
);
await queryRunner.query(
`ALTER TABLE "review" DROP CONSTRAINT "FK_b9d6f5a7e9a73348c3dbf005d80"`,
);
await queryRunner.query(
`ALTER TABLE "review" DROP CONSTRAINT "FK_30909ac2f5b587d9944fb7cf3ef"`,
);
await queryRunner.query(
`ALTER TABLE "message" DROP CONSTRAINT "FK_c72d82fa0e8699a141ed6cc41b3"`,
);
await queryRunner.query(
`ALTER TABLE "follow" DROP CONSTRAINT "FK_e9f68503556c5d72a161ce38513"`,
);
await queryRunner.query(
`ALTER TABLE "follow" DROP CONSTRAINT "FK_550dce89df9570f251b6af2665a"`,
);
await queryRunner.query(
`ALTER TABLE "product" DROP CONSTRAINT "FK_329b8ae12068b23da547d3b4798"`,
);
await queryRunner.query(`DROP TABLE "product_notification"`);
await queryRunner.query(`DROP TABLE "notification"`);
await queryRunner.query(`DROP TABLE "conversation"`);
await queryRunner.query(`DROP TABLE "user"`);
await queryRunner.query(`DROP TABLE "review"`);
await queryRunner.query(`DROP TABLE "avatar"`);
await queryRunner.query(`DROP TABLE "message"`);
await queryRunner.query(`DROP TABLE "follow"`);
await queryRunner.query(`DROP TABLE "profile"`);
await queryRunner.query(`DROP TABLE "product"`);
await queryRunner.query(`DROP TABLE "image"`);
await queryRunner.query(`DROP TABLE "admin_notifications"`);
}
}
2 changes: 1 addition & 1 deletion server/ecommerce/ormconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { AdminNotifications } from 'src/utils/entities/adminNotifications.entity
import { DataSource } from 'typeorm';

export let config: PostgresConnectionOptions;
if (process.env.IS_PRODUCTION === 'true') {
if (process.env.IS_PRODUCTION == 'true') {
config = {
type: 'postgres',
database: process.env.EXTERNAL_POSTGRES_DB,
Expand Down
2 changes: 1 addition & 1 deletion server/ecommerce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"scripts": {
"build": "nest build",
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
"start": "nest start",
"start": "NODE_OPTIONS='--max_old_space_size=400' nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",
"start:prod": "node dist/main",
Expand Down
2 changes: 1 addition & 1 deletion server/ecommerce/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ async function bootstrap() {
});
const { httpAdapter } = app.get(HttpAdapterHost);
app.useGlobalFilters(new ZodExceptionFilter(httpAdapter));
await app.listen(3000);
await app.listen(process.env.PORT || 3000);
}
bootstrap();

0 comments on commit d6de60a

Please sign in to comment.