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 -- CreateEnum
CREATE TYPE "Frequency" AS ENUM ('PUNCTUAL', 'RECURRENT'); CREATE TYPE "Frequency" AS ENUM ('PUNCTUAL', 'RECURRENT');
-- CreateEnum
CREATE TYPE "AddressType" AS ENUM ('HOUSE_NUMBER', 'STREET_ADDRESS', 'LOCALITY', 'VENUE', 'OTHER');
-- CreateTable -- CreateTable
CREATE TABLE "ad" ( CREATE TABLE "ad" (
"uuid" UUID NOT NULL, "uuid" UUID NOT NULL,
@ -20,15 +17,16 @@ CREATE TABLE "ad" (
"friTime" TIMESTAMPTZ, "friTime" TIMESTAMPTZ,
"satTime" TIMESTAMPTZ, "satTime" TIMESTAMPTZ,
"sunTime" TIMESTAMPTZ, "sunTime" TIMESTAMPTZ,
"monMargin" INTEGER, "monMargin" INTEGER NOT NULL,
"tueMargin" INTEGER, "tueMargin" INTEGER NOT NULL,
"wedMargin" INTEGER, "wedMargin" INTEGER NOT NULL,
"thuMargin" INTEGER, "thuMargin" INTEGER NOT NULL,
"friMargin" INTEGER, "friMargin" INTEGER NOT NULL,
"satMargin" INTEGER, "satMargin" INTEGER NOT NULL,
"sunMargin" INTEGER, "sunMargin" INTEGER NOT NULL,
"seatsDriver" SMALLINT NOT NULL, "seatsDriver" SMALLINT NOT NULL,
"seatsPassenger" SMALLINT NOT NULL, "seatsPassenger" SMALLINT NOT NULL,
"strict" BOOLEAN NOT NULL,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
@ -48,24 +46,12 @@ CREATE TABLE "address" (
"locality" TEXT, "locality" TEXT,
"postalCode" TEXT, "postalCode" TEXT,
"country" TEXT, "country" TEXT,
"type" "AddressType", "countryCode" TEXT,
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
CONSTRAINT "address_pkey" PRIMARY KEY ("uuid") 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 -- AddForeignKey
ALTER TABLE "address" ADD CONSTRAINT "address_adUuid_fkey" FOREIGN KEY ("adUuid") REFERENCES "ad"("uuid") ON DELETE CASCADE ON UPDATE CASCADE; 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; int32 position =1;
float lon = 2; float lon = 2;
float lat = 3; float lat = 3;
string houseNumber = 4; optional string name =4;
string street = 5; optional string houseNumber = 5;
string locality = 6; optional string street = 6;
string postalCode = 7; optional string locality = 7;
string country = 8; optional string postalCode = 8;
AddressType type = 9; optional string country = 9;
optional string countryCode = 10;
} }
enum AddressType {
HOUSE_NUMBER = 1;
STREET_ADDRESS = 2;
LOCALITY = 3;
VENUE = 4;
OTHER = 5;
}
enum Frequency { enum Frequency {
PUNCTUAL = 1; PUNCTUAL = 1;

View File

@ -5,16 +5,13 @@ import {
IsBoolean, IsBoolean,
IsDate, IsDate,
IsInt, IsInt,
ValidateIf,
IsEnum, IsEnum,
IsNumber,
ValidateNested, ValidateNested,
IsLongitude, IsLongitude,
IsLatitude, IsLatitude,
} from 'class-validator'; } from 'class-validator';
import { Frequency } from '../entities/frequency.enum'; import { Frequency } from '../entities/frequency.enum';
import { Transform, Type } from 'class-transformer'; import { Transform, Type } from 'class-transformer';
import { AddressType } from '../entities/address.enum';
export class CreateAdRequest { export class CreateAdRequest {
@IsString() @IsString()