-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[ ] cordova
[ ] mongodb
[ ] mssql
[ ] mysql / mariadb
[ ] oracle
[x] postgres
[ ] sqlite
[ ] sqljs
[ ] react-native
[ ] expo
TypeORM version:
[x] latest
[ ] @next
[ ] 0.x.x (or put your version here)
Steps to reproduce or a small repository showing the problem:
I've created an entity, so my User entity has the following structure:
import {
Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, ManyToOne,
BeforeInsert, BeforeUpdate, JoinColumn
} from "typeorm";
import {Contains, IsInt, Length, IsEmail, IsFQDN, IsDate, Min, Max, MaxLength, MinLength} from "class-validator";
/**
* User Entity
*/
@Entity()
export class User {
@PrimaryGeneratedColumn()
id: number;
@Column({
name: "uuid",
type: "varchar",
length: 150,
unique: true
})
uuid: string;
@Column({
name: "email",
type: "varchar",
length: 180,
unique: true
})
@IsEmail()
@MaxLength(180, {
message: "Email is too long"
})
email: string;
@Column({
name: "username",
type: "varchar",
length: 50,
unique: true
})
@MinLength(3, {
message: "Username is too short"
})
@MaxLength(50, {
message: "Username is too long"
})
username: string;
@Column({
name: "password",
type: "varchar",
length: 150
})
password: string;
@Column({
name: "salt",
type: "varchar",
length: 150
})
salt: string;
@Column({
name: "first_name",
type: "varchar",
length: 150,
nullable: true
})
@MaxLength(150, {
message: "First name is too long"
})
firstName: string;
@Column({
name: "last_name",
type: "varchar",
length: 150,
nullable: true
})
@MaxLength(150, {
message: "Last name is too long"
})
lastName: string;
@Column({
name: "display_name",
type: "varchar",
length: 150,
nullable: true
})
@MaxLength(150, {
message: "Display name is too long"
})
displayName: string;
@Column({
name: "activation_code",
type: "varchar",
length: 150
})
activationCode: string;
@Column({
name: "roles",
type: "simple-array"
})
roles: string[];
@Column({
name: "created_at",
type: "timestamp"
})
@CreateDateColumn()
createdAt: Date;
@ManyToOne(type => User)
@JoinColumn({ name: "created_by_id" })
createdBy: User;
@Column({
name: "updated_at",
type: "timestamp"
})
@UpdateDateColumn()
updatedAt: Date;
@ManyToOne(type => User)
@JoinColumn({ name: "updated_by_id" })
updatedBy: User;
@Column({
name: "is_email_confirmed",
type: "boolean"
})
isEmailConfirmed: boolean;
@Column({
name: "is_active",
type: "boolean"
})
isActive: boolean;
/**
*
* @param {string} email
* @param {string} username
* @param {string} password
* @param {string} salt
* @param {string} displayName
* @param {string} activationCode
* @param {string[]} roles
* @param {number} isActive
*/
constructor(displayName?: string,
email?: string,
username?: string,
password?: string,
salt?: string,
activationCode?: string,
roles?: string[],
isEmailConfirmed?: boolean,
isActive?: boolean) {
this.email = email;
this.username = username;
this.password = password;
this.salt = salt;
this.displayName = displayName;
this.activationCode = activationCode;
this.roles = roles;
this.isEmailConfirmed = isEmailConfirmed;
this.isActive = isActive;
}
@BeforeInsert()
beforeCreate() {
this.createdAt = new Date();
this.updatedAt = this.createdAt;
}
@BeforeUpdate()
beforeUpdate() {
this.updatedAt = new Date();
}
}When I tried to generate the proper migration for it running:
ts-node ./node_modules/.bin/typeorm migration:generate -nI'm receiving this response:
node@133cd09eb3d4:/var/srv/app$ ts-node ./node_modules/.bin/typeorm migration:generate -n
Error during migration generation:
TypeError: str.replace is not a function
at Object.camelCase (/var/srv/app/src/util/StringUtils.ts:9:15)
at Function.MigrationGenerateCommand.getTemplate (/var/srv/app/src/commands/MigrationGenerateCommand.ts:118:16)
at Object.<anonymous> (/var/srv/app/src/commands/MigrationGenerateCommand.ts:88:62)
at step (/var/srv/app/node_modules/typeorm/commands/MigrationGenerateCommand.js:32:23)
at Object.next (/var/srv/app/node_modules/typeorm/commands/MigrationGenerateCommand.js:13:53)
at fulfilled (/var/srv/app/node_modules/typeorm/commands/MigrationGenerateCommand.js:4:58)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:228:7)Reactions are currently unavailable