adding migration and update proto

This commit is contained in:
Grégoire Chevalier 2023-05-11 11:17:47 +02:00
parent c3ce060b24
commit f4d7f050d3
3 changed files with 16 additions and 39 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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()