Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum not found if schema is set. #3563

Closed
GuilhermeReda opened this issue Apr 20, 2015 · 2 comments
Closed

enum not found if schema is set. #3563

GuilhermeReda opened this issue Apr 20, 2015 · 2 comments

Comments

@GuilhermeReda
Copy link
Contributor

@GuilhermeReda GuilhermeReda commented Apr 20, 2015

Test Code:

var Sequelize = require('sequelize');
var config  = require(__dirname + '/config/database.json')['production'];
var sequelize = new Sequelize(config.database, config.username, config.password, config);

"use strict";

var Foo = sequelize.define("Foo", {
  type: {
    type          : Sequelize.ENUM('A', 'B', 'C'),
    allowNull     : false
  }
}, {
  schema: 'foo'
});

sequelize.sync({force: true}).then(function () {
  console.log("Done");
});

Output:

Executing (default): DROP TABLE IF EXISTS "foo"."Foos" CASCADE;
Executing (default): DROP TABLE IF EXISTS "foo"."Foos" CASCADE;
Executing (default): SELECT t.typname enum_name, array_agg(e.enumlabel) enum_value FROM pg_type t JOIN pg_enum e ON t.oid = e.enumtypid JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace WHERE n.nspname = 'public'  AND t.typname='enum_foo_"foo"."Foos"_type'  GROUP BY 1
Executing (default): DROP TYPE IF EXISTS "enum_foo_foo.Foos_type"; CREATE TYPE "enum_foo_foo.Foos_type" AS ENUM('A', 'B', 'C');
Executing (default): CREATE TABLE IF NOT EXISTS "foo"."Foos" ("id"   SERIAL , "type" "enum_foo.Foos_type" NOT NULL, "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL, "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL, PRIMARY KEY ("id"));
Possibly unhandled SequelizeDatabaseError: typo "enum_foo.Foos_type" does not exists
    at module.exports.Query.formatError (\node\node_modules\sequelize\lib\dialects\postgres\query.js:415:16)
    at null.<anonymous> (\node\node_modules\sequelize\lib\dialects\postgres\query.js:110:21)
    at emit (events.js:95:17)
    at Query.handleError (\node\node_modules\pg\lib\query.js:99:8)
    at null.<anonymous> (\node\node_modules\pg\lib\client.js:166:26)
    at emit (events.js:95:17)
    at Socket.<anonymous> (\node\node_modules\pg\lib\connection.js:109:12)
    at Socket.emit (events.js:95:17)
    at Socket.<anonymous> (_stream_readable.js:765:14)
    at Socket.emit (events.js:92:17)
@GuilhermeReda GuilhermeReda changed the title enum not found schema is set. enum not found if schema is set. Apr 20, 2015
@kenkouot
Copy link

@kenkouot kenkouot commented Apr 26, 2015

Possibly related to #2785

@thuanmb
Copy link

@thuanmb thuanmb commented Jun 5, 2018

I got the same issue and I fixed it by remove the types which was defined when I ran my migration to create the same table.

For example, with your case, let try to remove the type by:

DROP TYPE enum_foo_foo.Foos_type

Then try to create the table again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants