From f4d7f050d3aad179c282d74b3fe4b5c4f56a26f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Chevalier?= Date: Thu, 11 May 2023 11:17:47 +0200 Subject: [PATCH] adding migration and update proto --- .../migration.sql | 32 ++++++------------- src/modules/ad/adapters/primaries/ad.proto | 20 ++++-------- .../ad/domain/dtos/create-ad.request.ts | 3 -- 3 files changed, 16 insertions(+), 39 deletions(-) rename prisma/migrations/{20230510123439_init => 20230511090552_init}/migration.sql (71%) diff --git a/prisma/migrations/20230510123439_init/migration.sql b/prisma/migrations/20230511090552_init/migration.sql similarity index 71% rename from prisma/migrations/20230510123439_init/migration.sql rename to prisma/migrations/20230511090552_init/migration.sql index efef8e6..e63ea4a 100644 --- a/prisma/migrations/20230510123439_init/migration.sql +++ b/prisma/migrations/20230511090552_init/migration.sql @@ -1,9 +1,6 @@ -- CreateEnum CREATE TYPE "Frequency" AS ENUM ('PUNCTUAL', 'RECURRENT'); --- CreateEnum -CREATE TYPE "AddressType" AS ENUM ('HOUSE_NUMBER', 'STREET_ADDRESS', 'LOCALITY', 'VENUE', 'OTHER'); - -- CreateTable CREATE TABLE "ad" ( "uuid" UUID NOT NULL, @@ -20,15 +17,16 @@ CREATE TABLE "ad" ( "friTime" TIMESTAMPTZ, "satTime" TIMESTAMPTZ, "sunTime" TIMESTAMPTZ, - "monMargin" INTEGER, - "tueMargin" INTEGER, - "wedMargin" INTEGER, - "thuMargin" INTEGER, - "friMargin" INTEGER, - "satMargin" INTEGER, - "sunMargin" INTEGER, + "monMargin" INTEGER NOT NULL, + "tueMargin" INTEGER NOT NULL, + "wedMargin" INTEGER NOT NULL, + "thuMargin" INTEGER NOT NULL, + "friMargin" INTEGER NOT NULL, + "satMargin" INTEGER NOT NULL, + "sunMargin" INTEGER NOT NULL, "seatsDriver" SMALLINT NOT NULL, "seatsPassenger" SMALLINT NOT NULL, + "strict" BOOLEAN NOT NULL, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, @@ -48,24 +46,12 @@ CREATE TABLE "address" ( "locality" TEXT, "postalCode" TEXT, "country" TEXT, - "type" "AddressType", + "countryCode" TEXT, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, CONSTRAINT "address_pkey" PRIMARY KEY ("uuid") ); --- CreateIndex -CREATE INDEX "ad_driver_idx" ON "ad"("driver"); - --- CreateIndex -CREATE INDEX "ad_passenger_idx" ON "ad"("passenger"); - --- CreateIndex -CREATE INDEX "ad_fromDate_idx" ON "ad"("fromDate"); - --- CreateIndex -CREATE INDEX "ad_toDate_idx" ON "ad"("toDate"); - -- AddForeignKey ALTER TABLE "address" ADD CONSTRAINT "address_adUuid_fkey" FOREIGN KEY ("adUuid") REFERENCES "ad"("uuid") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/src/modules/ad/adapters/primaries/ad.proto b/src/modules/ad/adapters/primaries/ad.proto index 3b37b64..4127a88 100644 --- a/src/modules/ad/adapters/primaries/ad.proto +++ b/src/modules/ad/adapters/primaries/ad.proto @@ -54,21 +54,15 @@ message Address { int32 position =1; float lon = 2; float lat = 3; - string houseNumber = 4; - string street = 5; - string locality = 6; - string postalCode = 7; - string country = 8; - AddressType type = 9; + optional string name =4; + optional string houseNumber = 5; + optional string street = 6; + optional string locality = 7; + optional string postalCode = 8; + optional string country = 9; + optional string countryCode = 10; } -enum AddressType { - HOUSE_NUMBER = 1; - STREET_ADDRESS = 2; - LOCALITY = 3; - VENUE = 4; - OTHER = 5; -} enum Frequency { PUNCTUAL = 1; diff --git a/src/modules/ad/domain/dtos/create-ad.request.ts b/src/modules/ad/domain/dtos/create-ad.request.ts index 0ef4480..81ebe4e 100644 --- a/src/modules/ad/domain/dtos/create-ad.request.ts +++ b/src/modules/ad/domain/dtos/create-ad.request.ts @@ -5,16 +5,13 @@ import { IsBoolean, IsDate, IsInt, - ValidateIf, IsEnum, - IsNumber, ValidateNested, IsLongitude, IsLatitude, } from 'class-validator'; import { Frequency } from '../entities/frequency.enum'; import { Transform, Type } from 'class-transformer'; -import { AddressType } from '../entities/address.enum'; export class CreateAdRequest { @IsString()