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/OracleAdapter.php 1 location
|
@@ 202-211 (lines=10) @@
|
| 199 |
|
} |
| 200 |
|
|
| 201 |
|
// set the primary key(s) |
| 202 |
|
if (isset($options['primary_key'])) { |
| 203 |
|
$pkSql = sprintf('CONSTRAINT PK_%s PRIMARY KEY (', substr($table->getName(), 0, 28)); |
| 204 |
|
if (is_string($options['primary_key'])) { // handle primary_key => 'id' |
| 205 |
|
$pkSql .= $this->quoteColumnName($options['primary_key']); |
| 206 |
|
} elseif (is_array($options['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id') |
| 207 |
|
$pkSql .= implode(',', array_map([$this, 'quoteColumnName'], $options['primary_key'])); |
| 208 |
|
} |
| 209 |
|
$pkSql .= ')'; |
| 210 |
|
$sqlBuffer[] = $pkSql; |
| 211 |
|
} |
| 212 |
|
|
| 213 |
|
// set the foreign keys |
| 214 |
|
$foreignKeys = $table->getForeignKeys(); |
src/Phinx/Db/Adapter/PostgresAdapter.php 1 location
|
@@ 224-235 (lines=12) @@
|
| 221 |
|
} |
| 222 |
|
|
| 223 |
|
// set the primary key(s) |
| 224 |
|
if (isset($options['primary_key'])) { |
| 225 |
|
$sql = rtrim($sql); |
| 226 |
|
$sql .= sprintf(' CONSTRAINT %s_pkey PRIMARY KEY (', $table->getName()); |
| 227 |
|
if (is_string($options['primary_key'])) { // handle primary_key => 'id' |
| 228 |
|
$sql .= $this->quoteColumnName($options['primary_key']); |
| 229 |
|
} elseif (is_array($options['primary_key'])) { // handle primary_key => array('tag_id', 'resource_id') |
| 230 |
|
$sql .= implode(',', array_map([$this, 'quoteColumnName'], $options['primary_key'])); |
| 231 |
|
} |
| 232 |
|
$sql .= ')'; |
| 233 |
|
} else { |
| 234 |
|
$sql = rtrim($sql, ', '); // no primary keys |
| 235 |
|
} |
| 236 |
|
|
| 237 |
|
$sql .= ');'; |
| 238 |
|
|
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 |