@@ -3,6 +3,7 @@ const Shadow = require('./driver/shadow');
33
44class STD {
55 constructor ( { schema, modSchema : mod } , driver ) {
6+ this . validations = { } ;
67 this . driver = driver ;
78 this . indizies = schema . i ;
89 this . schema = schema . c ;
@@ -98,16 +99,50 @@ class STD {
9899 let alter = { } ;
99100 if ( this . schema [ t ] ) {
100101 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- ) ;
102+ if ( this . validations . columnStrategies !== true ) {
103+ if (
104+ this . driver . _meta &&
105+ this . driver . _meta . supports &&
106+ this . driver . _meta . supports . optionParam === true
107+ ) {
108+ /**
109+ * This is a validation only, no action will be taken unless throwing
110+ * errors.
111+ *
112+ * The driver needs to respect the options properly.
113+ */
114+ switch ( o . columnStrategy ) {
115+ case 'defaultValue' :
116+ break ;
117+ case 'delay' :
118+ break ;
119+ default :
120+ if ( ! o . columnStrategy ) {
121+ throw new Error (
122+ 'Can not drop a notNull column without providing a' +
123+ ' recreation strategy.'
124+ ) ;
125+ }
126+ throw new Error (
127+ `There is no such column recreation strategy "${
128+ o . columnStrategy
129+ } !"`
130+ ) ;
131+ }
132+ } else {
133+ throw new Error (
134+ 'This driver does not support optionParameters which are' +
135+ ' required to provide a recreation strategy.'
136+ ) ;
137+ }
138+
139+ if ( ! this . driver . _meta . supports . columnStrategies ) {
140+ throw new Error (
141+ 'This driver does not support column recreation strategies.'
142+ ) ;
143+ }
144+
145+ this . validations . columnStrategies = true ;
111146 }
112147 }
113148 this . modS [ t ] = { } ;
0 commit comments