Skip to content

PostgreSQL: Model file writing for tables with same names but different schemas #530

Open
@paulkr

Description

When writing your models to files using the option directory, there is no distinction for tables with the same name but different schemas.

Example:

Given the following 2 tables in a database schema1.users and schema2.users, where schema1 and schema2 are different schemas, when creating the models using the file writing option, the initial model file will get overridden as the table names are the same, despite being different tables. So there will be only 1 model file generated.

In the above example, the init-models.js file generated would look like this:

var DataTypes = require("sequelize").DataTypes;
var _users = require("./users");
var _users = require("./users");

function initModels(sequelize) {
  var users = _users(sequelize, DataTypes);
  var users = _users(sequelize, DataTypes);


  return {
    users,
    users,
  };
}
module.exports = initModels;
module.exports.initModels = initModels;
module.exports.default = initModels;

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions