Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit 11d4a209
authored
Jul 16, 2018
by
Paul Mowat
Committed by
Sushant
Jul 16, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(postgres): drop enum support (#9641)
1 parent
37145bc9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
0 deletions
lib/query-interface.js
test/integration/query-interface/dropEnum.test.js
lib/query-interface.js
View file @
11d4a20
...
...
@@ -293,6 +293,27 @@ class QueryInterface {
}
/**
* Drop specified enum from database, Postgres Only
* @param {String} [enumName] Enum name to drop
* @param {Object} options Query options
*
* @return {Promise}
* @private
*/
dropEnum
(
enumName
,
options
)
{
if
(
this
.
sequelize
.
getDialect
()
!==
'postgres'
)
{
return
Promise
.
resolve
();
}
options
=
options
||
{};
return
this
.
sequelize
.
query
(
this
.
QueryGenerator
.
pgEnumDrop
(
null
,
null
,
this
.
QueryGenerator
.
pgEscapeAndQuote
(
enumName
)),
_
.
assign
({},
options
,
{
raw
:
true
})
);
}
/**
* Drop all enums from database, Postgres Only
*
* @param {Object} options Query options
...
...
test/integration/query-interface/dropEnum.test.js
0 → 100644
View file @
11d4a20
'use strict'
;
const
chai
=
require
(
'chai'
);
const
expect
=
chai
.
expect
;
const
Support
=
require
(
__dirname
+
'/../support'
);
const
DataTypes
=
require
(
__dirname
+
'/../../../lib/data-types'
);
const
dialect
=
Support
.
getTestDialect
();
describe
(
Support
.
getTestDialectTeaser
(
'QueryInterface'
),
()
=>
{
beforeEach
(
function
()
{
this
.
sequelize
.
options
.
quoteIdenifiers
=
true
;
this
.
queryInterface
=
this
.
sequelize
.
getQueryInterface
();
});
afterEach
(
function
()
{
return
this
.
sequelize
.
dropAllSchemas
();
});
describe
(
'dropEnum'
,
()
=>
{
beforeEach
(
function
()
{
return
this
.
queryInterface
.
createTable
(
'menus'
,
{
structuretype
:
{
type
:
DataTypes
.
ENUM
(
'menus'
,
'submenu'
,
'routine'
),
allowNull
:
true
},
sequence
:
{
type
:
DataTypes
.
INTEGER
,
allowNull
:
true
},
name
:
{
type
:
DataTypes
.
STRING
,
allowNull
:
true
}
});
});
if
(
dialect
===
'postgres'
)
{
it
(
'should be able to drop the specified enum'
,
function
()
{
return
this
.
queryInterface
.
removeColumn
(
'menus'
,
'structuretype'
).
bind
(
this
).
then
(
function
()
{
return
this
.
queryInterface
.
pgListEnums
(
'menus'
);
}).
then
(
enumList
=>
{
expect
(
enumList
).
to
.
have
.
lengthOf
(
1
);
expect
(
enumList
[
0
]).
to
.
have
.
property
(
'enum_name'
).
and
.
to
.
equal
(
'enum_menus_structuretype'
);
}).
then
(()
=>
{
return
this
.
queryInterface
.
dropEnum
(
'enum_menus_structuretype'
);
}).
then
(()
=>
{
return
this
.
queryInterface
.
pgListEnums
(
'menus'
);
}).
then
(
enumList
=>
{
expect
(
enumList
).
to
.
be
.
an
(
'array'
);
expect
(
enumList
).
to
.
have
.
lengthOf
(
0
);
});
});
}
});
});
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment