简体   繁体   中英

Unable to connect aws rds using Sailsjs adapters

I am able to access my aws rds mysql instance from mysql CLI. But same configuration is not working for sailsjs database adapter.

this is my ./config/env/production.js

connections: {
    mysqlServer: {
      host: "demo.c4a1v1iyi4x1.ap-southeast-1.rds.amazonaws.com",
      user: "username",
      password: "password",
      database: "mydb",
    },
  }, 

I have modified my ./config/models.js to create tables

/**
 * Default model configuration
 * (sails.config.models)
 *
 * Unless you override them, the following properties will be included
 * in each of your models.
 *
 * For more info on Sails models, see:
 * http://sailsjs.org/#/documentation/concepts/ORM
 */

module.exports.models = {

  /***************************************************************************
  *                                                                          *
  * Your app's default connection. i.e. the name of one of your app's        *
  * connections (see `config/connections.js`)                                *
  *                                                                          *
  ***************************************************************************/
  connection: 'mysqlServer',

  /***************************************************************************
  *                                                                          *
  * How and whether Sails will attempt to automatically rebuild the          *
  * tables/collections/etc. in your schema.                                  *
  *                                                                          *
  * See http://sailsjs.org/#/documentation/concepts/ORM/model-settings.html  *
  *                                                                          *
  * In a production environment (NODE_ENV==="production") Sails always uses  *
  * migrate:"safe" to protect inadvertent deletion of your data.             *
  * However development has a few other options for convenience:             *
  *                                                                          *
  * safe - never auto-migrate my database(s). I will do it myself (by hand)  *
  * alter - auto-migrate, but attempt to keep existing data (experimental)   *
  * drop - wipe/drop ALL my data and rebuild models every time I lift Sails  *
  *                                                                          *
  ***************************************************************************/
  migrate: 'alter',

};

Using above configurations , sails.js is unable to connect or create tables in aws rds instance.Can anyone help me with this . Thanks in advance.

Got the fault. Sails.Js in production env forces waterline to use 'migrate:safe' instead of 'alter' or 'drop'. So , any table creation was inhibited. Hence, I override the development config with production with 'migrate:alter' and ran sails lift. Bingo! ALL TABLES WERE CREATED.

Sails was able to connect with rds but its own configuration was not allowing it to create table.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM