Reputation: 313
I wanted to add mock data to my project. So I tried to do migration with typeorm.
npx typeorm migration:create -n FakePosts
After creating migration, I used queryRunner in typeorm to insert data.
1642424231242235-FakePosts.ts
import {MigrationInterface, QueryRunner} from "typeorm";
export class FakePosts1642424231242235 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
queryRunner.query(`
insert into post (userId, type, title, texts) values (1, 3, 'Tulpan', 'Nullam sit amet
turpis elementum ligula vehicula consequat. Morbi a ipsum. Integer a nibh.
In quis justo. Maecenas rhoncus aliquam lacus. Morbi quis tortor id nulla ultrices
aliquet.');
insert into post (userId, type, title, texts) values (1, 3, 'Look, Up in the Sky! The
Amazing Story of Superman', 'Proin leo odio, porttitor id, consequat in, consequat ut, nulla.
Sed accumsan felis. Ut at dolor quis odio consequat varius.');
`)
}
public async down(queryRunner: QueryRunner): Promise<void> {
}
}
inside of index.ts
await conn.runMigrations();
But I got this Error.
error: Error: ER_PARSE_ERROR: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'insert into post (userId, type, title, texts) values (1, 3, 'Look, Up in the ...' at line 2
I think that I don't have any errors in my SQL syntax but mysql is mad at me.
What is the problem?
Upvotes: 1
Views: 330