{"action":"opened","issue":{"url":"https://api.github.com/repos/sequelize/sequelize/issues/4388","labels_url":"https://api.github.com/repos/sequelize/sequelize/issues/4388/labels{/name}","comments_url":"https://api.github.com/repos/sequelize/sequelize/issues/4388/comments","events_url":"https://api.github.com/repos/sequelize/sequelize/issues/4388/events","html_url":"https://github.com/sequelize/sequelize/issues/4388","id":102948773,"number":4388,"title":"PostgreSQL - queryInterface.createTable - unable to set  the correct schema in attributes that reference other tables.","user":{"login":"gbahamondez","id":3533121,"avatar_url":"https://avatars.githubusercontent.com/u/3533121?v=3","gravatar_id":"","url":"https://api.github.com/users/gbahamondez","html_url":"https://github.com/gbahamondez","followers_url":"https://api.github.com/users/gbahamondez/followers","following_url":"https://api.github.com/users/gbahamondez/following{/other_user}","gists_url":"https://api.github.com/users/gbahamondez/gists{/gist_id}","starred_url":"https://api.github.com/users/gbahamondez/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gbahamondez/subscriptions","organizations_url":"https://api.github.com/users/gbahamondez/orgs","repos_url":"https://api.github.com/users/gbahamondez/repos","events_url":"https://api.github.com/users/gbahamondez/events{/privacy}","received_events_url":"https://api.github.com/users/gbahamondez/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-08-25T04:58:46Z","updated_at":"2015-08-25T04:58:46Z","closed_at":null,"body":"```javascript\r\nqueryInterface.createTable('user', {\r\n        id : {\r\n          type : Sequelize.INTEGER,\r\n          primaryKey: true,\r\n          autoIncrement: true\r\n        },\r\n        profile_id : {\r\n          type: Sequelize.INTEGER,\r\n          references: {\r\n            model : 'profile',\r\n            key: 'id',\r\n            onUpdate: 'CASCADE',\r\n            onDelete: 'RESTRICT'\r\n          },\r\n        }\r\n      }, {\r\n      schema: 'test_schema'\r\n     })\r\n```\r\n\r\nUsing the code above, the create table query for create statement is:\r\n\r\n```sql\r\nCREATE TABLE IF NOT EXISTS \"test_schema\".\"user\" (\"id\"  SERIAL , \"profile_id\" INTEGER REFERENCES \"Profile\" (\"id\"), PRIMARY KEY (\"id\"));\r\n```\r\nWhich, is wrong,  giving the next  error: \"relation profile doesn't exist\" because is not referencing to the correct PostgreSQL schema (\"test_schema\").\r\n\r\nThe generated query should reference to the \"test_schema\" on the FK creation.\r\n\r\n```sql\r\nCREATE TABLE IF NOT EXISTS \"test_schema\".\"user\" (\"id\"  SERIAL , \"profile_id\" INTEGER REFERENCES \"test_schema\".\"profile\" (\"id\"), PRIMARY KEY (\"id\"));\r\n```\r\n\r\nThere's no way to specify the schema of the referenced  table   in the attributes definition?\r\n\r\nOr i'm misunderstanding something?"}}