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

DB unable to migrate any script #55

Closed duanvnc closed 4 years ago

duanvnc commented 4 years ago

Describe the bug pgdb unable to migrate the database structure

To Reproduce Steps to reproduce the behavior:

  1. Create .env file with info:
    NODE_ENV=production
    LOG_LEVEL=info
    DB_HOST=localhost
    DB_PORT=5432
    DB_USER=root
    DB_PASSWORD=root
    DB_DATABASE=lbstarter
    DB_SCHEMA=
    REDIS_HOST=localhost
    REDIS_PORT=6379
    REDIS_URL=
    REDIS_PASSWORD=
    REDIS_DATABASE=0
    JWT_SECRET=plmnkoxswqaz
    JWT_ISSUER=lb_api
    AUDIT_SCHEMA=logs
    USER_TEMP_PASSWORD=temp123!@#
    DEFAULT_ROLE=super_admin
  2. PostgresSQL and Redis are connected already.
  3. Run 3 commands to setup project:
    • npm install
    • npm run build
    • npm run db:migrate
  4. No error message found.
    
    ➜  loopback4-starter git:(master) ✗ npm run db:migrate

loopback4-starter@1.0.1 db:migrate /Users/myaccount/loopback4-starter ./node_modules/db-migrate/bin/db-migrate up --config './migrations/database.json'

Expected behavior The Postgres databases: lbstarter and logs structures should be seen on PostgresSQL database

Screenshots

PostgresDB photo: https://prnt.sc/tlmyv8

mayank-SFIN571 commented 4 years ago

Hi @duanvnc I just wanted to confirm one thing before we start debugging this. Did you make the database with the name 'lbstarter' (the one i can see in your '.env' file) before running these scripts?

I am asking this because the migration scripts in this project will only create the schema and the tables for you. You need to manually add the database.

I tried running these command with your configuration and this was the result.

image

duanvnc commented 4 years ago

@mayank-SFIN571 It seems db-migrate-pg's bugs.

I have resolved my issue after update packages to these:

"db-migrate": "^0.11.11",
 "db-migrate-pg": "^1.2.2",

Thank you!