Bigbool98
Bigbool98

Reputation: 104

How to add a new column to an existing table in TypeOrm using Migrations

I have a node typescript typeorm app.

I'm trying to stay with syncronize: false since i've read that in production it's safer to have it false or it may cause loss of data.. Anyway...

I have some entities that were created by migrations (and in DBeaver everything was ok), but i've noticed that i forgot to add a column in a specific table. Now i saw that to add a column to that table i should create a new migration called for example "AddNewColumnToTable" with queryRunned.AddColumn etc...

Everything is ok since i try to run that migration to create that new column.

I tried npx typeorm migration:run but i get errors like "cannot use import statement outside a module. I tried to run all the migrations but nothing changes.. it says no migrations are in pending (obviously i also runned npm run build before running those commands)

Any help would be delightfull! Thanks!

Upvotes: 0

Views: 550

Answers (1)

Bigbool98
Bigbool98

Reputation: 104

Ok my whole problems where due to my appDataSource where i load all the FakeName.migration.ts and my file was missing of that .migration part in the fileName, so it wasn't detected as a migration and it wouldnt start

Upvotes: 0

Related Questions