FoalTS / foal

Full-featured Node.js framework, with no complexity. 🚀 Simple and easy to use, TypeScript-based and well-documented.
https://foalts.org/
MIT License
1.88k stars 137 forks source link

migrations and different database types for dev/production #984

Closed warren-gallagher closed 2 years ago

warren-gallagher commented 2 years ago

I've been developing a new app using sqlite3 and have just started preparing for production using PostgreSQL.

The migrations were created while I was using sqlite3.

When I ran:

NODE_ENV=production npm run migrations

I got errors regarding AUTOINCREMENT.

I deleted my migrations and ran:

NODE_ENV=production npm run make migrations
NODE_ENV=production npm run migrations

Everything worked this time.

Do I need different migrations for different database types? If so, is there a way to manage this by maintaining different migrations scripts in FoalTS?

BTW, in just a few hours I was able to convert my application from using local Disk and sqlite to using S3 Disk and PostgreSQL in only a few hours. Great job on this framework.

kingdun3284 commented 2 years ago

You need migration for different db type. This is maintained by the orm which abstract the logic between different connector.

warren-gallagher commented 2 years ago

OK. Unfortunate but understandable. It may be worth mentioning that in the database section of the documentation.

I was able to modify ormconfig.js, config/default.json and config/production.js so that I can maintain different migrations for different database types.