Skip to content

postgres tables created in migration cannot be accessed #588

@m2sillanpaa

Description

@m2sillanpaa

What you are doing?

I'm having problems creating models with sequelizer. Or more accurately I can create models and migrate them, but I cannot access, modify or delete them via psql.

I'm creating the model like this:

sequelize model:generate --name Device --attributes pid:string ip:string

output:

Sequelize CLI [Node: 4.6.1, CLI: 3.0.0, ORM: 4.22.6]

WARNING: This version of Sequelize CLI is not fully compatible with
Sequelize v4. https://github.com/sequelize/cli#sequelize-support

New model was created at
/home/matti/workspace/db_demo/server/models/device.js . New migration
was created at
/home/matti/workspace/db_demo/server/migrations/20171114134820-Device.js
.

migrating like this:

$ sequelize db:migrate

Sequelize CLI [Node: 4.6.1, CLI: 3.0.0, ORM: 4.22.6]

WARNING: This version of Sequelize CLI is not fully compatible with
Sequelize v4. https://github.com/sequelize/cli#sequelize-support

Loaded configuration file "server/config/config.json". Using
environment "development". sequelize deprecated String based operators
are now deprecated. Please use Symbol based operators for better
security, read more at
http://docs.sequelizejs.com/manual/tutorial/querying.html#operators
node_modules/sequelize/lib/sequelize.js:236:13
== 20171114134820-create-device: migrating =======
== 20171114134820-create-device: migrated (0.044s)

after this I can see the tables in pqsl.

my user credentials (using it as matti):

                                List of roles  
   Role name |                         Attributes                         | Member of 
  -----------+------------------------------------------------------------+-----------  
   matti     | Superuser, Create DB                                       | {}  
   postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}

I'm working in Ubuntu 16.04.

I've reverted the migration and dropped the db just to be certain. But it didn't have any effect. Nor did restarting the postgres.

I can create, list and delete the db:ses as user "matti" from psql. But not the ones generated by the sequelizer.

migration file:

'use strict';
module.exports = {
  up: (queryInterface, Sequelize) => {
    return queryInterface.createTable('Devices', {
      id: {
        allowNull: false,
        autoIncrement: true,
        primaryKey: true,
        type: Sequelize.INTEGER
      },
      pid: {
        type: Sequelize.STRING
      },
      ip: {
        type: Sequelize.STRING
      },
      createdAt: {
        allowNull: false,
        type: Sequelize.DATE
      },
      updatedAt: {
        allowNull: false,
        type: Sequelize.DATE
      }
    });
  },
  down: (queryInterface, Sequelize) => {
    return queryInterface.dropTable('Devices');
  }
};

What do you expect to happen?

Working tables.

What is actually happening?

 device-dev=# \d
           List of relations  
 Schema |      Name      |   Type   | Owner 
--------+----------------+----------+-------  
 public | Devices        | table    | matti  
 public | Devices_id_seq | sequence | matti  
 public | SequelizeMeta  | table    | matti

However I cannot list the table:

device-dev=# \d Devices 
Did not find any relation named "Devices".

used versions:
Sequelize: Sequelize CLI [Node: 4.6.1, CLI: 3.0.0, ORM: 4.22.6]
postgres: psql (PostgreSQL) 10.1
nodejs: v4.6.1
npm: 2.15.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions