typeorm_metadata table not in migrations when generating view sql

See original GitHub issue

Issue type:

[ ] question [x] bug report [ ] feature request [ ] documentation issue

Database system/driver:

[ ] cordova [ ] mongodb [ ] mssql [x] mysql / mariadb [ ] oracle [ ] postgres [ ] cockroachdb [ ] 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: When generating the SQL for a view with the cli command “migration:generate” the command creates a table called typeorm_metadata in the database without adding it to the migrations file. If you drop the schema and run the migrations again or run the migration on another machine it fails because the table doesn’t exist.

A solution would be if the migration:run command creates the typeorm_metadata table if it doesn’t exist like migration:generate does or if the migration:generate command adds the create SQL script to the migration.

A workaround is to add the sql create script for typeorm_metadata to your migrations manually.

Up: CREATE TABLE `typeorm_metadata` (`type` varchar(255) NOT NULL,`database` varchar(255) DEFAULT NULL,`schema` varchar(255) DEFAULT NULL,`table` varchar(255) DEFAULT NULL,`name` varchar(255) DEFAULT NULL,`value` text) ENGINE=InnoDB

Down: DROP TABLE typeorm_metadata

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:37
  • Comments:20 (7 by maintainers)

github_iconTop GitHub Comments

24reactions
moltarcommented, May 15, 2020

Same query for PG:

            CREATE TABLE typeorm_metadata (
                "type" varchar(255) NOT NULL,
                "database" varchar(255) DEFAULT NULL,
                "schema" varchar(255) DEFAULT NULL,
                "table" varchar(255) DEFAULT NULL,
                "name" varchar(255) DEFAULT NULL,
                "value" text
            )
8reactions
andrei9669commented, Aug 4, 2021

still persists

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typeorm migration not detecting changes properly
I found the problem. When executing migration script, it creates a migration ts file in migration folder but the previous migration files in ......
Read more >
Migrations - typeorm - GitBook
A migration is just a single file with sql queries to update a database schema and apply new changes to an existing database....
Read more >
Using CLI | TypeORM Docs
Generate a migration from existing table schema. Automatic migration generation creates a new migration file and writes all sql queries that must be...
Read more >
Prisma | NestJS - A progressive Node.js framework
In this section, you'll create two new tables in your database using Prisma Migrate. Prisma Migrate generates SQL migration files for your declarative...
Read more >
TypeORM vs Prisma
TypeORM is a traditional ORM which maps tables to model classes. ... Prisma Migrate then allows to generate SQL migrations from the Prisma...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found