@@ -2,7 +2,8 @@ const Promise = require('bluebird');
22const Shadow = require ( './driver/shadow' ) ;
33
44class STD {
5- constructor ( { schema, modSchema : mod } ) {
5+ constructor ( { schema, modSchema : mod } , driver ) {
6+ this . driver = driver ;
67 this . indizies = schema . i ;
78 this . schema = schema . c ;
89 this . foreign = schema . f ;
@@ -93,9 +94,22 @@ class STD {
9394 return this . createTable . apply ( this , args ) ;
9495 }
9596
96- removeColumn ( t , c ) {
97+ removeColumn ( t , c , o ) {
9798 let alter = { } ;
9899 if ( this . schema [ t ] ) {
100+ if ( this . schema [ t ] [ c ] . notNull === true ) {
101+ if ( this . driver . _meta . supports . optionParam === true ) {
102+ throw new Error (
103+ 'Can not drop a notNull column without providing a' +
104+ ' recreation strategy.'
105+ ) ;
106+ } else {
107+ throw new Error (
108+ 'This driver does not support optionParameters which are' +
109+ ' required to provide a recreation strategy.'
110+ ) ;
111+ }
112+ }
99113 this . modS [ t ] = { } ;
100114 this . modS [ t ] [ c ] = this . schema [ t ] [ c ] ;
101115 delete this . schema [ t ] [ c ] ;
@@ -265,14 +279,14 @@ const noLearnError = prop => {
265279module . exports = {
266280 getInterface : ( context , file , driver , internals ) => {
267281 if ( context . learnable ) {
268- const _std = new STD ( internals ) ;
282+ const _std = new STD ( internals , context ) ;
269283 return Shadow . overshadow (
270284 driver ,
271285 Object . assign ( _std , context . learnable ) ,
272286 noLearnError
273287 ) ;
274288 }
275289
276- return Shadow . overshadow ( driver , new STD ( internals ) , noLearnError ) ;
290+ return Shadow . overshadow ( driver , new STD ( internals , context ) , noLearnError ) ;
277291 }
278292} ;
0 commit comments