Skip to content

Commit

Permalink
Criando tabela de agendamentos
Browse files Browse the repository at this point in the history
  • Loading branch information
danilo-vieira committed Sep 30, 2020
1 parent 8317955 commit 3893bd7
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 2 deletions.
8 changes: 7 additions & 1 deletion nivel-02/02-iniciando-back-end-do-app/ormconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
"port": 5432,
"username": "docker",
"password": "docker",
"database": "gostack_gobarber"
"database": "gostack_gobarber",
"migrations": [
"./src/database/migrations/*.ts"
],
"cli": {
"migrationsDir": "./src/database/migrations"
}
}
3 changes: 2 additions & 1 deletion nivel-02/02-iniciando-back-end-do-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"license": "MIT",
"scripts": {
"build": "tsc",
"dev:server": "ts-node-dev --inspect --transpile-only --ignore-watch node_modules src/server.ts"
"dev:server": "ts-node-dev --inspect --transpile-only --ignore-watch node_modules src/server.ts",
"typeorm": "ts-node-dev ./node_modules/typeorm/cli.js"
},
"dependencies": {
"date-fns": "^2.16.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';

export default class CreateAppointments1601469847641
implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'appointments',
columns: [
{
name: 'id',
type: 'varchar',
isPrimary: true,
generationStrategy: 'uuid',
},
{
name: 'provider',
type: 'varchar',
isNullable: false,
},
{
name: 'date',
type: 'timestamp with time zone',
isNullable: false,
},
],
}),
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('appointments');
}
}

0 comments on commit 3893bd7

Please sign in to comment.