@@ -47,81 +47,81 @@ class {{ name }} extends AbstractMigration
4747 */
4848 public function up (): void
4949 {
50- {% for tableName , tableDiff in data % }
51- { % set hasRemoveFK = tableDiff [' constraints' ][' remove' ] is not empty or tableDiff [' indexes' ][' remove' ] is
50+ {% for tableName , tableDiff in data % }
51+ { % ~ set hasRemoveFK = tableDiff [' constraints' ][' remove' ] is not empty or tableDiff [' indexes' ][' remove' ] is
5252not empty % }
53- { % if hasRemoveFK % }
53+ { % ~ if hasRemoveFK % }
5454 $this -> table(' {{ tableName }}' )
55- { % endif % }
56- { % if tableDiff [' constraints' ][' remove' ] is not empty % }
57- { % for constraintName , constraintDefinition in tableDiff [' constraints' ][' remove' ] % }
55+ { % ~ endif % }
56+ { % ~ if tableDiff [' constraints' ][' remove' ] is not empty % }
57+ { % ~ for constraintName , constraintDefinition in tableDiff [' constraints' ][' remove' ] % }
5858 -> dropForeignKey([], ' {{ constraintName }}' )
59- { % endfor % }
60- { % endif % }
61- { % if tableDiff [' indexes' ][' remove' ] is not empty % }
62- { % for indexName , indexDefinition in tableDiff [' indexes' ][' remove' ] % }
59+ { % ~ endfor % }
60+ { % ~ endif % }
61+ { % ~ if tableDiff [' indexes' ][' remove' ] is not empty % }
62+ { % ~ for indexName , indexDefinition in tableDiff [' indexes' ][' remove' ] % }
6363 -> removeIndexByName(' {{ indexName }}' )
64- { % endfor % }
65- { % endif % }
66- { % if hasRemoveFK % }
64+ { % ~ endfor % }
65+ { % ~ endif % }
66+ { % ~ if hasRemoveFK % }
6767 -> update();
68- { % endif % }
69- { % if tableDiff [' columns' ][' remove' ] is not empty or tableDiff [' columns' ][' changed' ] is not empty % }
68+ { % ~ endif % }
69+ { % ~ if tableDiff [' columns' ][' remove' ] is not empty or tableDiff [' columns' ][' changed' ] is not empty % }
7070
7171 {{ Migration . tableStatement(tableName , true ) | raw }}
72- { % if tableDiff [' columns' ][' remove' ] is not empty % }
73- { % for columnName , columnDefinition in tableDiff [' columns' ][' remove' ] % }
72+ { % ~ if tableDiff [' columns' ][' remove' ] is not empty % }
73+ { % ~ for columnName , columnDefinition in tableDiff [' columns' ][' remove' ] % }
7474 -> removeColumn(' {{ columnName }}' )
75- { % endfor % }
76- { % endif % }
77- { % if tableDiff [' columns' ][' changed' ] is not empty % }
78- { % for columnName , columnAttributes in tableDiff [' columns' ][' changed' ] % }
79- { % set type = columnAttributes [' type' ] % }
80- { % set columnAttributes = Migration . getColumnOption(columnAttributes ) % }
81- { % set columnAttributes = Migration . stringifyList(columnAttributes , {' indent' : 4 , ' remove' :
75+ { % ~ endfor % }
76+ { % ~ endif % }
77+ { % ~ if tableDiff [' columns' ][' changed' ] is not empty % }
78+ { % ~ for columnName , columnAttributes in tableDiff [' columns' ][' changed' ] % }
79+ { % ~ set type = columnAttributes [' type' ] % }
80+ { % ~ set columnAttributes = Migration . getColumnOption(columnAttributes ) % }
81+ { % ~ set columnAttributes = Migration . stringifyList(columnAttributes , {' indent' : 4 , ' remove' :
8282 [' type' ]}) % }
8383 -> changeColumn(' {{ columnName }}' , ' {{ type }}' , [{{ columnAttributes | raw }}])
84- { % endfor % }
85- { % endif -% }
86- { % if Migration . wasTableStatementGeneratedFor(tableName ) % }
84+ { % ~ endfor % }
85+ { % ~ endif -% }
86+ { % ~ if Migration . wasTableStatementGeneratedFor(tableName ) % }
8787 -> update();
88- { % endif % }
89- { % endif % }
90- {% endfor % }
91- {% if tables [' add' ] is not empty % }
92- {{ Migration . element(' Migrations.create-tables' , {' tables' : tables [' add' ], ' autoId' : autoId , ' useSchema' :
88+ { % ~ endif % }
89+ { % ~ endif % }
90+ {% endfor % }
91+ {% if tables [' add' ] is not empty % }
92+ {{ ~ Migration . element(' Migrations.create-tables' , {' tables' : tables [' add' ], ' autoId' : autoId , ' useSchema' :
9393 true }) | raw - }}
94- {% endif % }
95- {% for tableName , tableDiff in data % }
96- { % if tableDiff [' columns' ][' add' ] is not empty or tableDiff [' indexes' ][' add' ] is not empty % }
94+ {% endif % }
95+ {% for tableName , tableDiff in data % }
96+ { % ~ if tableDiff [' columns' ][' add' ] is not empty or tableDiff [' indexes' ][' add' ] is not empty % }
9797
9898 {{ Migration . tableStatement(tableName , true ) | raw }}
99- { % if tableDiff [' columns' ][' add' ] is not empty % }
100- {{ Migration . element(' Migrations.add-columns' , {' columns' : tableDiff [' columns' ][' add' ]}) | raw - }}
101- { % endif -% }
102- { % if tableDiff [' indexes' ][' add' ] is not empty % }
103- {{ Migration . element(' Migrations.add-indexes' , {' backend' : backend , ' indexes' : tableDiff [' indexes' ][' add' ]}) | raw - }}
104- { % endif -% }
105- { % if Migration . wasTableStatementGeneratedFor(tableName ) % }
99+ { % ~ if tableDiff [' columns' ][' add' ] is not empty % }
100+ {{ ~ Migration . element(' Migrations.add-columns' , {' columns' : tableDiff [' columns' ][' add' ]}) | raw - }}
101+ { % ~ endif -% }
102+ { % ~ if tableDiff [' indexes' ][' add' ] is not empty % }
103+ {{ ~ Migration . element(' Migrations.add-indexes' , {' backend' : backend , ' indexes' : tableDiff [' indexes' ][' add' ]}) | raw - }}
104+ { % ~ endif -% }
105+ { % ~ if Migration . wasTableStatementGeneratedFor(tableName ) % }
106106 -> update();
107- { % endif -% }
108- { % endif -% }
109- {% endfor -% }
110- {% for tableName , tableDiff in data -% }
111- { % if tableDiff [' constraints' ][' add' ] is not empty -% }
107+ { % ~ endif -% }
108+ { % ~ endif -% }
109+ {% endfor -% }
110+ {% for tableName , tableDiff in data -% }
111+ { % if tableDiff [' constraints' ][' add' ] is not empty -% }
112112
113- {{ Migration . element(
114- ' Migrations.add-foreign-keys' ,
115- {' constraints' : tableDiff [' constraints' ][' add' ], ' table' : tableName , ' backend' : backend }
116- ) | raw - }}
117- { % endif -% }
118- {% endfor -% }
119- {% if tables [' remove' ] is not empty % }
120- { % for tableName , table in tables [' remove' ] % }
113+ {{ ~ Migration . element(
114+ ' Migrations.add-foreign-keys' ,
115+ {' constraints' : tableDiff [' constraints' ][' add' ], ' table' : tableName , ' backend' : backend }
116+ ) | raw - }}
117+ { % ~ endif -% }
118+ {% endfor -% }
119+ {% if tables [' remove' ] is not empty % }
120+ { % ~ for tableName , table in tables [' remove' ] % }
121121
122122 $this -> table(' {{ tableName }}' )-> drop()-> save();
123- { % endfor % }
124- {% endif % }
123+ { % ~ endfor % }
124+ {% endif % }
125125 }
126126
127127 /**
@@ -134,87 +134,87 @@ not empty %}
134134 */
135135 public function down (): void
136136 {
137- {% set returnedData = Migration . getReturnedData() % }
138- {% set constraints = [] % }
139- {% set emptyLine = false % }
140- {% if returnedData [' dropForeignKeys' ] is not empty % }
141- { % for table , columnsList in returnedData [' dropForeignKeys' ] % }
142- { % set maxKey = columnsList | length - 1 % }
143- { % if emptyLine % }
137+ {% set returnedData = Migration . getReturnedData() % }
138+ {% set constraints = [] % }
139+ {% set emptyLine = false % }
140+ {% if returnedData [' dropForeignKeys' ] is not empty % }
141+ { % ~ for table , columnsList in returnedData [' dropForeignKeys' ] % }
142+ { % ~ set maxKey = columnsList | length - 1 % }
143+ { % ~ if emptyLine % }
144144
145- { % else % }
146- { % set emptyLine = true % }
147- { % endif % }
145+ { % ~ else % }
146+ { % ~ set emptyLine = true % }
147+ { % ~ endif % }
148148 $this -> table(' {{ table }}' )
149- { % for key , columns in columnsList % }
149+ { % ~ for key , columns in columnsList % }
150150 -> dropForeignKey(
151151 {{ columns | raw }}
152152 ){{ (key == maxKey ) ? ' ->save();' : ' ' }}
153- { % endfor -% }
154- { % endfor -% }
155- {% endif -% }
156- {% if tables [' remove' ] is not empty -% }
157- {{ Migration . element(' Migrations.create-tables' , {
153+ { % ~ endfor -% }
154+ { % ~ endfor -% }
155+ {% endif -% }
156+ {% if tables [' remove' ] is not empty -% }
157+ {{ ~ Migration . element(' Migrations.create-tables' , {
158158 ' tables' : tables [' remove' ],
159159 ' autoId' : autoId ,
160160 ' useSchema' : true
161161 }) | raw - }}
162- {% endif -% }
163- {% for tableName , tableDiff in data -% }
164- { % do Migration . resetTableStatementGenerationFor(tableName ) % }
165- { % if tableDiff [' indexes' ][' add' ] is not empty % }
162+ {% endif -% }
163+ {% for tableName , tableDiff in data -% }
164+ { % ~ do Migration . resetTableStatementGenerationFor(tableName ) % }
165+ { % ~ if tableDiff [' indexes' ][' add' ] is not empty % }
166166
167167 $this -> table(' {{ tableName }}' )
168- { % for indexName , index in tableDiff [' indexes' ][' add' ] % }
168+ { % ~ for indexName , index in tableDiff [' indexes' ][' add' ] % }
169169 -> removeIndexByName(' {{ indexName }}' )
170- { % endfor % }
170+ { % ~ endfor % }
171171 -> update();
172- { % endif % }
173- { % if (tableDiff [' columns' ][' remove' ] is not empty or
172+ { % ~ endif % }
173+ { % ~ if (tableDiff [' columns' ][' remove' ] is not empty or
174174 tableDiff [' columns' ][' changed' ] is not empty or
175175 tableDiff [' columns' ][' add' ] is not empty or
176176 tableDiff [' indexes' ][' remove' ] is not empty ) % }
177177
178178 {{ Migration . tableStatement(tableName , true ) | raw }}
179- { % endif % }
180- { % if tableDiff [' columns' ][' remove' ] is not empty -% }
181- {{ Migration . element(' Migrations.add-columns' , {' columns' : tableDiff [' columns' ][' remove' ]}) | raw - }}
182- { % endif -% }
183- { % if tableDiff [' columns' ][' changed' ] is not empty -% }
184- { % set oldTableDef = dumpSchema [tableName ] -% }
185- { % for columnName , columnAttributes in tableDiff [' columns' ][' changed' ] -% }
186- { % set columnAttributes = oldTableDef . getColumn(columnName ) -% }
187- { % set type = columnAttributes [' type' ] -% }
188- { % set columnAttributes = Migration . getColumnOption(columnAttributes ) -% }
189- { % set columnAttributes = Migration . stringifyList(columnAttributes , {' indent' : 4 , ' remove' : [' type' ]}) % }
179+ { % ~ endif % }
180+ { % ~ if tableDiff [' columns' ][' remove' ] is not empty -% }
181+ {{ ~ Migration . element(' Migrations.add-columns' , {' columns' : tableDiff [' columns' ][' remove' ]}) | raw - }}
182+ { % ~ endif -% }
183+ { % ~ if tableDiff [' columns' ][' changed' ] is not empty -% }
184+ { % ~ set oldTableDef = dumpSchema [tableName ] -% }
185+ { % ~ for columnName , columnAttributes in tableDiff [' columns' ][' changed' ] -% }
186+ { % ~ set columnAttributes = oldTableDef . getColumn(columnName ) -% }
187+ { % ~ set type = columnAttributes [' type' ] -% }
188+ { % ~ set columnAttributes = Migration . getColumnOption(columnAttributes ) -% }
189+ { % ~ set columnAttributes = Migration . stringifyList(columnAttributes , {' indent' : 4 , ' remove' : [' type' ]}) % }
190190 -> changeColumn(' {{ columnName }}' , ' {{ type }}' , [{{ columnAttributes | raw }}])
191- { % endfor -% }
192- { % endif -% }
193- { % if tableDiff [' columns' ][' add' ] is not empty % }
194- { % for columnName , columnAttributes in tableDiff [' columns' ][' add' ] % }
191+ { % ~ endfor -% }
192+ { % ~ endif -% }
193+ { % ~ if tableDiff [' columns' ][' add' ] is not empty % }
194+ { % ~ for columnName , columnAttributes in tableDiff [' columns' ][' add' ] % }
195195 -> removeColumn(' {{ columnName }}' )
196- { % endfor -% }
197- { % endif -% }
198- { % if tableDiff [' indexes' ][' remove' ] is not empty -% }
199- {{ Migration . element(' Migrations.add-indexes' , {' indexes' : tableDiff [' indexes' ][' remove' ]}) | raw - }}
200- { % endif -% }
201- { % if Migration . wasTableStatementGeneratedFor(tableName ) % }
196+ { % ~ endfor -% }
197+ { % ~ endif -% }
198+ { % ~ if tableDiff [' indexes' ][' remove' ] is not empty -% }
199+ {{ ~ Migration . element(' Migrations.add-indexes' , {' indexes' : tableDiff [' indexes' ][' remove' ]}) | raw - }}
200+ { % ~ endif -% }
201+ { % ~ if Migration . wasTableStatementGeneratedFor(tableName ) % }
202202 -> update();
203- { % endif % }
204- {% endfor % }
205- {% for tableName , tableDiff in data % }
206- { % if tableDiff [' constraints' ][' remove' ] is not empty % }
207- {{ Migration . element(
208- ' Migrations.add-foreign-keys' ,
209- {' constraints' : tableDiff [' constraints' ][' remove' ], ' table' : tableName }
203+ { % ~ endif % }
204+ {% endfor % }
205+ {% for tableName , tableDiff in data % }
206+ { % ~ if tableDiff [' constraints' ][' remove' ] is not empty % }
207+ {{ ~ Migration . element(
208+ ' Migrations.add-foreign-keys' ,
209+ {' constraints' : tableDiff [' constraints' ][' remove' ], ' table' : tableName }
210210 ) | raw - }}
211- { % endif % }
212- {% endfor % }
213- {% if tables [' add' ] is not empty % }
211+ { % ~ endif % }
212+ {% endfor % }
213+ {% if tables [' add' ] is not empty % }
214214
215- { % for tableName , table in tables [' add' ] % }
215+ { % ~ for tableName , table in tables [' add' ] % }
216216 $this -> table(' {{ tableName }}' )-> drop()-> save();
217- { % endfor % }
218- {% endif % }
217+ { % ~ endfor % }
218+ {% endif % }
219219 }
220220}
0 commit comments