Skip to content

Instantly share code, notes, and snippets.

@Ionaru
Created January 2, 2019 11:53
Show Gist options
  • Save Ionaru/5ac6f41759dc72230c266bc8ee1bf593 to your computer and use it in GitHub Desktop.
Save Ionaru/5ac6f41759dc72230c266bc8ee1bf593 to your computer and use it in GitHub Desktop.
Running this code shows TypeORM dropping the `someText` column and recreating it.
import 'reflect-metadata'; // Required by TypeORM.
import { BaseEntity, Column, createConnection, Entity, PrimaryGeneratedColumn } from 'typeorm';
@Entity()
export class Bar extends BaseEntity {
@PrimaryGeneratedColumn()
public id!: number;
@Column({
type: 'text',
})
public someText!: string;
}
createConnection({
database: 'REDACTED',
entities: [Bar],
host: 'REDACTED',
logging: true,
password: 'REDACTED',
port: 3306,
synchronize: true,
type: 'mysql',
username: 'REDACTED'
}).then((connection) => {
console.log('Connected', connection.isConnected);
process.exit(0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment