Atualizando rotas das vans com lógica do locador
This commit is contained in:
@@ -29,6 +29,11 @@ export class CreateVansTable1655691282002 implements MigrationInterface {
|
||||
name: 'seats_number',
|
||||
type: 'numeric',
|
||||
},
|
||||
{
|
||||
name: 'document',
|
||||
type: 'varchar',
|
||||
isNullable: true
|
||||
},
|
||||
{
|
||||
name: 'created_at',
|
||||
type: 'timestamp',
|
||||
|
||||
@@ -9,11 +9,9 @@ export class CreateVanDocumentsTable1655692498005
|
||||
name: 'vanDocuments',
|
||||
columns: [
|
||||
{
|
||||
name: 'id_vanDocuments',
|
||||
type: 'uuid',
|
||||
name: 'document_van',
|
||||
type: 'varchar',
|
||||
isPrimary: true,
|
||||
generationStrategy: 'uuid',
|
||||
default: 'uuid_generate_v4()',
|
||||
},
|
||||
{
|
||||
name: 'vanLocator_id',
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { MigrationInterface, QueryRunner, TableForeignKey } from 'typeorm';
|
||||
|
||||
export class AddFKVanDocumentToVanDocumentsTable1655696991836
|
||||
implements MigrationInterface
|
||||
{
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.createForeignKey(
|
||||
'vanDocuments',
|
||||
new TableForeignKey({
|
||||
name: 'VanDocumentVanDocuments', // nome da FK, serve para referenciar numa exclusão pelo QueryRunner se necessário
|
||||
columnNames: ['document_van'], // coluna que vai virar FK
|
||||
referencedColumnNames: ['document'], // coluna PK da primeira tabela
|
||||
referencedTableName: 'vanDocuments', // nome da tabela que possui a PK
|
||||
onDelete: 'SET NULL',
|
||||
onUpdate: 'CASCADE',
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.dropForeignKey('vanDocuments', 'VanDocumentVanDocuments');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user