Code Duplication    Length = 12-12 lines in 4 locations

src/Phinx/Db/Adapter/MysqlAdapter.php 1 location

@@ 269-280 (lines=12) @@
266
        }
267
268
        // set the primary key(s)
269
        if (isset($options['primary_key'])) {
270
            $sql = rtrim($sql);
271
            $sql .= ' PRIMARY KEY (';
272
            if (is_string($options['primary_key'])) { // handle primary_key => 'id'
273
                $sql .= $this->quoteColumnName($options['primary_key']);
274
            } elseif (is_array($options['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id')
275
                $sql .= implode(',', array_map([$this, 'quoteColumnName'], $options['primary_key']));
276
            }
277
            $sql .= ')';
278
        } else {
279
            $sql = substr(rtrim($sql), 0, -1); // no primary keys
280
        }
281
282
        // set the indexes
283
        foreach ($indexes as $index) {

src/Phinx/Db/Adapter/PostgresAdapter.php 1 location

@@ 228-239 (lines=12) @@
225
        }
226
227
         // set the primary key(s)
228
        if (isset($options['primary_key'])) {
229
            $sql = rtrim($sql);
230
            $sql .= sprintf(' CONSTRAINT %s PRIMARY KEY (', $this->quoteColumnName($parts['table'] . '_pkey'));
231
            if (is_string($options['primary_key'])) { // handle primary_key => 'id'
232
                $sql .= $this->quoteColumnName($options['primary_key']);
233
            } elseif (is_array($options['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id')
234
                $sql .= implode(',', array_map([$this, 'quoteColumnName'], $options['primary_key']));
235
            }
236
            $sql .= ')';
237
        } else {
238
            $sql = rtrim($sql, ', '); // no primary keys
239
        }
240
241
        $sql .= ');';
242

src/Phinx/Db/Adapter/SQLiteAdapter.php 1 location

@@ 209-220 (lines=12) @@
206
        }
207
208
        // set the primary key(s)
209
        if (isset($options['primary_key'])) {
210
            $sql = rtrim($sql);
211
            $sql .= ' PRIMARY KEY (';
212
            if (is_string($options['primary_key'])) { // handle primary_key => 'id'
213
                $sql .= $this->quoteColumnName($options['primary_key']);
214
            } elseif (is_array($options['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id')
215
                $sql .= implode(',', array_map([$this, 'quoteColumnName'], $options['primary_key']));
216
            }
217
            $sql .= ')';
218
        } else {
219
            $sql = substr(rtrim($sql), 0, -1); // no primary keys
220
        }
221
222
        $sql = rtrim($sql) . ');';
223
        // execute the sql

src/Phinx/Db/Adapter/RedshiftAdapter.php 1 location

@@ 52-63 (lines=12) @@
49
		}
50
		
51
		// set the primary key(s)
52
		if ( isset( $options['primary_key'] ) ) {
53
			$sql = rtrim( $sql );
54
			$sql .= sprintf( ' CONSTRAINT %s PRIMARY KEY (', $this->quoteColumnName( $parts['table'] . '_pkey' ) );
55
			if ( is_string( $options['primary_key'] ) ) { // handle primary_key => 'id'
56
				$sql .= $this->quoteColumnName( $options['primary_key'] );
57
			} elseif ( is_array( $options['primary_key'] ) ) { // handle primary_key => array('tag_id', 'resource_id')
58
				$sql .= implode( ',', array_map( [ $this, 'quoteColumnName' ], $options['primary_key'] ) );
59
			}
60
			$sql .= ')';
61
		} else {
62
			$sql = rtrim( $sql, ', ' ); // no primary keys
63
		}
64
		$sql .= ') ';
65
		
66
		// process redshift sortkeys & distkey