create-schema.test.js
1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
'use strict';
const Support = require('../support');
const expectsql = Support.expectsql;
const current = Support.sequelize;
const sql = current.dialect.queryGenerator;
describe(Support.getTestDialectTeaser('SQL'), () => {
if (current.dialect.name === 'postgres') {
describe('dropSchema', () => {
it('IF EXISTS', () => {
expectsql(sql.dropSchema('foo'), {
postgres: 'DROP SCHEMA IF EXISTS foo CASCADE;'
});
});
});
describe('createSchema', () => {
before(function() {
this.version = current.options.databaseVersion;
});
after(function() {
current.options.databaseVersion = this.version;
});
it('9.2.0 or above', () => {
current.options.databaseVersion = '9.2.0';
expectsql(sql.createSchema('foo'), {
postgres: 'CREATE SCHEMA IF NOT EXISTS foo;'
});
});
it('below 9.2.0', () => {
current.options.databaseVersion = '9.0.0';
expectsql(sql.createSchema('foo'), {
postgres: 'CREATE SCHEMA foo;'
});
});
});
}
});