sourcefuse / loopback4-starter

Loopback 4 starter application. Multi-tenant architecture supported. Authentication, Authorization, Soft deletes, environment vars, Audit logs, included.
MIT License
158 stars 59 forks source link

Using SQL Server #17

Closed sherif2011 closed 5 years ago

sherif2011 commented 5 years ago

Hello, I tried this and it worked great. Now I am trying to get it to work with MS Sql Server. I am stuck with migration and am getting error :ifError got unwanted exception: Connection terminated unexpectedly. I installed "loopback-connector-mssql": "^3.3.0" I modified .env to include connection information

Only thing I have doubts about is the database.json "driver":"pg", should this be changed to something else? What? Also do I need to install sql server migration drivers? to replace "db-migrate-pg" ?

Thanks for advising.

Sherif

sherif2011 commented 5 years ago

Ok, I think I passed this issue by installing db-migrate-mssql and setting "driver":"mssql". Now I am getting The "config.server" property is required and must be of type string

sherif2011 commented 5 years ago

Please feel free to check my code here.

samarpan-b commented 5 years ago

Yes for each type of db, you will need separate driver of db-migrate and separate connector of loopback as well. A quick glance at your code, I think you need to set server property in database.json. But I really doubt that it will work satisfactorily. From the official docs of db-migrate - https://db-migrate.readthedocs.io/en/latest/#official-supported-databases. Officially it only supports MySql, Postgres, sqlite3, Mongodb. You may have to use some other db-migration library or use loopback migrations.

Some of the other migration libraries that support sql server - Postgrator, node-sql-migrations

For using loopback migrations, refer here - https://loopback.io/doc/en/lb4/Database-migrations.html

sherif2011 commented 5 years ago

Thanks @samarpan-b I will try loopback migrations!

sherif2011 commented 5 years ago

I will stick to postgres for now. Thanks!