Typeorm: Migration class name should have a UNIX timestamp appended.

Created on 12 Jan 2018  路  1Comment  路  Source: typeorm/typeorm

Hello! I run
ts-node ./node_modules/typeorm/cli.js migrations:run
after:

Error: ClientApp migration name is wrong. Migration class name should have a UNIX timestamp appended.

Why migration name is ClientApp? Help please.

Exception lines?

migration:
1515769694450-userAndApp.ts

import {MigrationInterface, QueryRunner} from "typeorm";

export class userAndApp1515769694450 implements MigrationInterface {

    public async up(queryRunner: QueryRunner): Promise<any> {
        await queryRunner.query(`CREATE TABLE "client_app" ("createdAt" TIMESTAMP, "updatedAt" TIMESTAMP, "deletedAt" TIMESTAMP, "id" SERIAL NOT NULL, "key" text NOT NULL, "name" text NOT NULL, "domain" text NOT NULL, "description" text NOT NULL, "status" integer NOT NULL, PRIMARY KEY("id"))`);
    }

    public async down(queryRunner: QueryRunner): Promise<any> {
        await queryRunner.query(`DROP TABLE "client_app"`);
    }

}


ClientApp.ts

import { Entity, Column, PrimaryGeneratedColumn, OneToMany } from 'typeorm';
import { Audit } from './audit.entity';

@Entity()
export class ClientApp extends Audit {
    @PrimaryGeneratedColumn() id: number;
    @Column('text') key: string;
    @Column('text') name: string;
    @Column('text') domain: string;
    @Column('text') description: string;
    @Column() status: number;
}

Audit.ts

import { Entity, Column } from 'typeorm';

export class Audit {

    @Column({ type: 'timestamp', nullable: true })
    createdAt: number;
    @Column({ type: 'timestamp', nullable: true })
    updatedAt?: number;
    @Column({ type: 'timestamp', nullable: true })
    deletedAt?: number;
}

Im use

"typeorm": "^0.1.11",
 "typescript": "^2.5.2",
"@types/node": "^8.5.8",
"nodemon": "^1.12.1",
 "ts-node": "3.3.0",

ormConfig:

{
   "name": "default",
   "type": "postgres",
   "host": "docker.local",
   "port": 5432,
   "username": "postgres",
   "password": "mysecretpassword",
   "database": "oauth",
   "synchronize": true,
   "logging": false,
   "entities": [
      "src/entity/**/*.ts"
    ],
    "migrations": [
      "src/entity/**/*.ts"
   ],
   "subscribers": [
      "src/subscriber/**/*.ts"
   ],
   "cli": {
      "entitiesDir": "src/entity",
      "migrationsDir": "src/migration",
      "subscribersDir": "src/subscriber"
   }
}

Most helpful comment

馃樀 Sorry, I'm write "src/entity/**/*.ts" vs "src/migration/**/*.ts"

typeorm the best))

>All comments

馃樀 Sorry, I'm write "src/entity/**/*.ts" vs "src/migration/**/*.ts"

typeorm the best))

Was this page helpful?
0 / 5 - 0 ratings

Related issues

juanjalvarez picture juanjalvarez  路  3Comments

SPAHI4 picture SPAHI4  路  3Comments

brunosiqueira picture brunosiqueira  路  3Comments

arthurvasconcelos picture arthurvasconcelos  路  3Comments

natanielkd picture natanielkd  路  3Comments