SQLiteGrammar.php 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838
  1. <?php
  2. namespace Illuminate\Database\Schema\Grammars;
  3. use RuntimeException;
  4. use Illuminate\Support\Fluent;
  5. use Doctrine\DBAL\Schema\Index;
  6. use Illuminate\Database\Connection;
  7. use Illuminate\Database\Schema\Blueprint;
  8. class SQLiteGrammar extends Grammar
  9. {
  10. /**
  11. * The possible column modifiers.
  12. *
  13. * @var array
  14. */
  15. protected $modifiers = ['Nullable', 'Default', 'Increment'];
  16. /**
  17. * The columns available as serials.
  18. *
  19. * @var array
  20. */
  21. protected $serials = ['bigInteger', 'integer', 'mediumInteger', 'smallInteger', 'tinyInteger'];
  22. /**
  23. * Compile the query to determine if a table exists.
  24. *
  25. * @return string
  26. */
  27. public function compileTableExists()
  28. {
  29. return "select * from sqlite_master where type = 'table' and name = ?";
  30. }
  31. /**
  32. * Compile the query to determine the list of columns.
  33. *
  34. * @param string $table
  35. * @return string
  36. */
  37. public function compileColumnListing($table)
  38. {
  39. return 'pragma table_info('.$this->wrap(str_replace('.', '__', $table)).')';
  40. }
  41. /**
  42. * Compile a create table command.
  43. *
  44. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  45. * @param \Illuminate\Support\Fluent $command
  46. * @return string
  47. */
  48. public function compileCreate(Blueprint $blueprint, Fluent $command)
  49. {
  50. return sprintf('%s table %s (%s%s%s)',
  51. $blueprint->temporary ? 'create temporary' : 'create',
  52. $this->wrapTable($blueprint),
  53. implode(', ', $this->getColumns($blueprint)),
  54. (string) $this->addForeignKeys($blueprint),
  55. (string) $this->addPrimaryKeys($blueprint)
  56. );
  57. }
  58. /**
  59. * Get the foreign key syntax for a table creation statement.
  60. *
  61. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  62. * @return string|null
  63. */
  64. protected function addForeignKeys(Blueprint $blueprint)
  65. {
  66. $foreigns = $this->getCommandsByName($blueprint, 'foreign');
  67. return collect($foreigns)->reduce(function ($sql, $foreign) {
  68. // Once we have all the foreign key commands for the table creation statement
  69. // we'll loop through each of them and add them to the create table SQL we
  70. // are building, since SQLite needs foreign keys on the tables creation.
  71. $sql .= $this->getForeignKey($foreign);
  72. if (! is_null($foreign->onDelete)) {
  73. $sql .= " on delete {$foreign->onDelete}";
  74. }
  75. // If this foreign key specifies the action to be taken on update we will add
  76. // that to the statement here. We'll append it to this SQL and then return
  77. // the SQL so we can keep adding any other foreign constraints onto this.
  78. if (! is_null($foreign->onUpdate)) {
  79. $sql .= " on update {$foreign->onUpdate}";
  80. }
  81. return $sql;
  82. }, '');
  83. }
  84. /**
  85. * Get the SQL for the foreign key.
  86. *
  87. * @param \Illuminate\Support\Fluent $foreign
  88. * @return string
  89. */
  90. protected function getForeignKey($foreign)
  91. {
  92. // We need to columnize the columns that the foreign key is being defined for
  93. // so that it is a properly formatted list. Once we have done this, we can
  94. // return the foreign key SQL declaration to the calling method for use.
  95. return sprintf(', foreign key(%s) references %s(%s)',
  96. $this->columnize($foreign->columns),
  97. $this->wrapTable($foreign->on),
  98. $this->columnize((array) $foreign->references)
  99. );
  100. }
  101. /**
  102. * Get the primary key syntax for a table creation statement.
  103. *
  104. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  105. * @return string|null
  106. */
  107. protected function addPrimaryKeys(Blueprint $blueprint)
  108. {
  109. if (! is_null($primary = $this->getCommandByName($blueprint, 'primary'))) {
  110. return ", primary key ({$this->columnize($primary->columns)})";
  111. }
  112. }
  113. /**
  114. * Compile alter table commands for adding columns.
  115. *
  116. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  117. * @param \Illuminate\Support\Fluent $command
  118. * @return array
  119. */
  120. public function compileAdd(Blueprint $blueprint, Fluent $command)
  121. {
  122. $columns = $this->prefixArray('add column', $this->getColumns($blueprint));
  123. return collect($columns)->map(function ($column) use ($blueprint) {
  124. return 'alter table '.$this->wrapTable($blueprint).' '.$column;
  125. })->all();
  126. }
  127. /**
  128. * Compile a unique key command.
  129. *
  130. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  131. * @param \Illuminate\Support\Fluent $command
  132. * @return string
  133. */
  134. public function compileUnique(Blueprint $blueprint, Fluent $command)
  135. {
  136. return sprintf('create unique index %s on %s (%s)',
  137. $this->wrap($command->index),
  138. $this->wrapTable($blueprint),
  139. $this->columnize($command->columns)
  140. );
  141. }
  142. /**
  143. * Compile a plain index key command.
  144. *
  145. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  146. * @param \Illuminate\Support\Fluent $command
  147. * @return string
  148. */
  149. public function compileIndex(Blueprint $blueprint, Fluent $command)
  150. {
  151. return sprintf('create index %s on %s (%s)',
  152. $this->wrap($command->index),
  153. $this->wrapTable($blueprint),
  154. $this->columnize($command->columns)
  155. );
  156. }
  157. /**
  158. * Compile a spatial index key command.
  159. *
  160. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  161. * @param \Illuminate\Support\Fluent $command
  162. * @throws \RuntimeException
  163. */
  164. public function compileSpatialIndex(Blueprint $blueprint, Fluent $command)
  165. {
  166. throw new RuntimeException('The database driver in use does not support spatial indexes.');
  167. }
  168. /**
  169. * Compile a foreign key command.
  170. *
  171. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  172. * @param \Illuminate\Support\Fluent $command
  173. * @return string
  174. */
  175. public function compileForeign(Blueprint $blueprint, Fluent $command)
  176. {
  177. // Handled on table creation...
  178. }
  179. /**
  180. * Compile a drop table command.
  181. *
  182. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  183. * @param \Illuminate\Support\Fluent $command
  184. * @return string
  185. */
  186. public function compileDrop(Blueprint $blueprint, Fluent $command)
  187. {
  188. return 'drop table '.$this->wrapTable($blueprint);
  189. }
  190. /**
  191. * Compile a drop table (if exists) command.
  192. *
  193. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  194. * @param \Illuminate\Support\Fluent $command
  195. * @return string
  196. */
  197. public function compileDropIfExists(Blueprint $blueprint, Fluent $command)
  198. {
  199. return 'drop table if exists '.$this->wrapTable($blueprint);
  200. }
  201. /**
  202. * Compile the SQL needed to drop all tables.
  203. *
  204. * @return string
  205. */
  206. public function compileDropAllTables()
  207. {
  208. return "delete from sqlite_master where type in ('table', 'index', 'trigger')";
  209. }
  210. /**
  211. * Compile a drop column command.
  212. *
  213. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  214. * @param \Illuminate\Support\Fluent $command
  215. * @param \Illuminate\Database\Connection $connection
  216. * @return array
  217. */
  218. public function compileDropColumn(Blueprint $blueprint, Fluent $command, Connection $connection)
  219. {
  220. $tableDiff = $this->getDoctrineTableDiff(
  221. $blueprint, $schema = $connection->getDoctrineSchemaManager()
  222. );
  223. foreach ($command->columns as $name) {
  224. $tableDiff->removedColumns[$name] = $connection->getDoctrineColumn(
  225. $this->getTablePrefix().$blueprint->getTable(), $name
  226. );
  227. }
  228. return (array) $schema->getDatabasePlatform()->getAlterTableSQL($tableDiff);
  229. }
  230. /**
  231. * Compile a drop unique key command.
  232. *
  233. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  234. * @param \Illuminate\Support\Fluent $command
  235. * @return string
  236. */
  237. public function compileDropUnique(Blueprint $blueprint, Fluent $command)
  238. {
  239. $index = $this->wrap($command->index);
  240. return "drop index {$index}";
  241. }
  242. /**
  243. * Compile a drop index command.
  244. *
  245. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  246. * @param \Illuminate\Support\Fluent $command
  247. * @return string
  248. */
  249. public function compileDropIndex(Blueprint $blueprint, Fluent $command)
  250. {
  251. $index = $this->wrap($command->index);
  252. return "drop index {$index}";
  253. }
  254. /**
  255. * Compile a drop spatial index command.
  256. *
  257. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  258. * @param \Illuminate\Support\Fluent $command
  259. * @throws \RuntimeException
  260. */
  261. public function compileDropSpatialIndex(Blueprint $blueprint, Fluent $command)
  262. {
  263. throw new RuntimeException('The database driver in use does not support spatial indexes.');
  264. }
  265. /**
  266. * Compile a rename table command.
  267. *
  268. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  269. * @param \Illuminate\Support\Fluent $command
  270. * @return string
  271. */
  272. public function compileRename(Blueprint $blueprint, Fluent $command)
  273. {
  274. $from = $this->wrapTable($blueprint);
  275. return "alter table {$from} rename to ".$this->wrapTable($command->to);
  276. }
  277. /**
  278. * Compile a rename index command.
  279. *
  280. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  281. * @param \Illuminate\Support\Fluent $command
  282. * @param \Illuminate\Database\Connection $connection
  283. * @return array
  284. */
  285. public function compileRenameIndex(Blueprint $blueprint, Fluent $command, Connection $connection)
  286. {
  287. $schemaManager = $connection->getDoctrineSchemaManager();
  288. $indexes = $schemaManager->listTableIndexes($this->getTablePrefix().$blueprint->getTable());
  289. $index = array_get($indexes, $command->from);
  290. if (! $index) {
  291. throw new RuntimeException("Index [{$command->from}] does not exist.");
  292. }
  293. $newIndex = new Index(
  294. $command->to, $index->getColumns(), $index->isUnique(),
  295. $index->isPrimary(), $index->getFlags(), $index->getOptions()
  296. );
  297. $platform = $schemaManager->getDatabasePlatform();
  298. return [
  299. $platform->getDropIndexSQL($command->from, $this->getTablePrefix().$blueprint->getTable()),
  300. $platform->getCreateIndexSQL($newIndex, $this->getTablePrefix().$blueprint->getTable()),
  301. ];
  302. }
  303. /**
  304. * Compile the command to enable foreign key constraints.
  305. *
  306. * @return string
  307. */
  308. public function compileEnableForeignKeyConstraints()
  309. {
  310. return 'PRAGMA foreign_keys = ON;';
  311. }
  312. /**
  313. * Compile the command to disable foreign key constraints.
  314. *
  315. * @return string
  316. */
  317. public function compileDisableForeignKeyConstraints()
  318. {
  319. return 'PRAGMA foreign_keys = OFF;';
  320. }
  321. /**
  322. * Compile the SQL needed to enable a writable schema.
  323. *
  324. * @return string
  325. */
  326. public function compileEnableWriteableSchema()
  327. {
  328. return 'PRAGMA writable_schema = 1;';
  329. }
  330. /**
  331. * Compile the SQL needed to disable a writable schema.
  332. *
  333. * @return string
  334. */
  335. public function compileDisableWriteableSchema()
  336. {
  337. return 'PRAGMA writable_schema = 0;';
  338. }
  339. /**
  340. * Create the column definition for a char type.
  341. *
  342. * @param \Illuminate\Support\Fluent $column
  343. * @return string
  344. */
  345. protected function typeChar(Fluent $column)
  346. {
  347. return 'varchar';
  348. }
  349. /**
  350. * Create the column definition for a string type.
  351. *
  352. * @param \Illuminate\Support\Fluent $column
  353. * @return string
  354. */
  355. protected function typeString(Fluent $column)
  356. {
  357. return 'varchar';
  358. }
  359. /**
  360. * Create the column definition for a text type.
  361. *
  362. * @param \Illuminate\Support\Fluent $column
  363. * @return string
  364. */
  365. protected function typeText(Fluent $column)
  366. {
  367. return 'text';
  368. }
  369. /**
  370. * Create the column definition for a medium text type.
  371. *
  372. * @param \Illuminate\Support\Fluent $column
  373. * @return string
  374. */
  375. protected function typeMediumText(Fluent $column)
  376. {
  377. return 'text';
  378. }
  379. /**
  380. * Create the column definition for a long text type.
  381. *
  382. * @param \Illuminate\Support\Fluent $column
  383. * @return string
  384. */
  385. protected function typeLongText(Fluent $column)
  386. {
  387. return 'text';
  388. }
  389. /**
  390. * Create the column definition for a integer type.
  391. *
  392. * @param \Illuminate\Support\Fluent $column
  393. * @return string
  394. */
  395. protected function typeInteger(Fluent $column)
  396. {
  397. return 'integer';
  398. }
  399. /**
  400. * Create the column definition for a big integer type.
  401. *
  402. * @param \Illuminate\Support\Fluent $column
  403. * @return string
  404. */
  405. protected function typeBigInteger(Fluent $column)
  406. {
  407. return 'integer';
  408. }
  409. /**
  410. * Create the column definition for a medium integer type.
  411. *
  412. * @param \Illuminate\Support\Fluent $column
  413. * @return string
  414. */
  415. protected function typeMediumInteger(Fluent $column)
  416. {
  417. return 'integer';
  418. }
  419. /**
  420. * Create the column definition for a tiny integer type.
  421. *
  422. * @param \Illuminate\Support\Fluent $column
  423. * @return string
  424. */
  425. protected function typeTinyInteger(Fluent $column)
  426. {
  427. return 'integer';
  428. }
  429. /**
  430. * Create the column definition for a small integer type.
  431. *
  432. * @param \Illuminate\Support\Fluent $column
  433. * @return string
  434. */
  435. protected function typeSmallInteger(Fluent $column)
  436. {
  437. return 'integer';
  438. }
  439. /**
  440. * Create the column definition for a float type.
  441. *
  442. * @param \Illuminate\Support\Fluent $column
  443. * @return string
  444. */
  445. protected function typeFloat(Fluent $column)
  446. {
  447. return 'float';
  448. }
  449. /**
  450. * Create the column definition for a double type.
  451. *
  452. * @param \Illuminate\Support\Fluent $column
  453. * @return string
  454. */
  455. protected function typeDouble(Fluent $column)
  456. {
  457. return 'float';
  458. }
  459. /**
  460. * Create the column definition for a decimal type.
  461. *
  462. * @param \Illuminate\Support\Fluent $column
  463. * @return string
  464. */
  465. protected function typeDecimal(Fluent $column)
  466. {
  467. return 'numeric';
  468. }
  469. /**
  470. * Create the column definition for a boolean type.
  471. *
  472. * @param \Illuminate\Support\Fluent $column
  473. * @return string
  474. */
  475. protected function typeBoolean(Fluent $column)
  476. {
  477. return 'tinyint(1)';
  478. }
  479. /**
  480. * Create the column definition for an enumeration type.
  481. *
  482. * @param \Illuminate\Support\Fluent $column
  483. * @return string
  484. */
  485. protected function typeEnum(Fluent $column)
  486. {
  487. return sprintf(
  488. 'varchar check ("%s" in (%s))',
  489. $column->name,
  490. $this->quoteString($column->allowed)
  491. );
  492. }
  493. /**
  494. * Create the column definition for a json type.
  495. *
  496. * @param \Illuminate\Support\Fluent $column
  497. * @return string
  498. */
  499. protected function typeJson(Fluent $column)
  500. {
  501. return 'text';
  502. }
  503. /**
  504. * Create the column definition for a jsonb type.
  505. *
  506. * @param \Illuminate\Support\Fluent $column
  507. * @return string
  508. */
  509. protected function typeJsonb(Fluent $column)
  510. {
  511. return 'text';
  512. }
  513. /**
  514. * Create the column definition for a date type.
  515. *
  516. * @param \Illuminate\Support\Fluent $column
  517. * @return string
  518. */
  519. protected function typeDate(Fluent $column)
  520. {
  521. return 'date';
  522. }
  523. /**
  524. * Create the column definition for a date-time type.
  525. *
  526. * @param \Illuminate\Support\Fluent $column
  527. * @return string
  528. */
  529. protected function typeDateTime(Fluent $column)
  530. {
  531. return 'datetime';
  532. }
  533. /**
  534. * Create the column definition for a date-time (with time zone) type.
  535. *
  536. * Note: "SQLite does not have a storage class set aside for storing dates and/or times."
  537. * @link https://www.sqlite.org/datatype3.html
  538. *
  539. * @param \Illuminate\Support\Fluent $column
  540. * @return string
  541. */
  542. protected function typeDateTimeTz(Fluent $column)
  543. {
  544. return $this->typeDateTime($column);
  545. }
  546. /**
  547. * Create the column definition for a time type.
  548. *
  549. * @param \Illuminate\Support\Fluent $column
  550. * @return string
  551. */
  552. protected function typeTime(Fluent $column)
  553. {
  554. return 'time';
  555. }
  556. /**
  557. * Create the column definition for a time (with time zone) type.
  558. *
  559. * @param \Illuminate\Support\Fluent $column
  560. * @return string
  561. */
  562. protected function typeTimeTz(Fluent $column)
  563. {
  564. return $this->typeTime($column);
  565. }
  566. /**
  567. * Create the column definition for a timestamp type.
  568. *
  569. * @param \Illuminate\Support\Fluent $column
  570. * @return string
  571. */
  572. protected function typeTimestamp(Fluent $column)
  573. {
  574. return $column->useCurrent ? 'datetime default CURRENT_TIMESTAMP' : 'datetime';
  575. }
  576. /**
  577. * Create the column definition for a timestamp (with time zone) type.
  578. *
  579. * @param \Illuminate\Support\Fluent $column
  580. * @return string
  581. */
  582. protected function typeTimestampTz(Fluent $column)
  583. {
  584. return $this->typeTimestamp($column);
  585. }
  586. /**
  587. * Create the column definition for a year type.
  588. *
  589. * @param \Illuminate\Support\Fluent $column
  590. * @return string
  591. */
  592. protected function typeYear(Fluent $column)
  593. {
  594. return $this->typeInteger($column);
  595. }
  596. /**
  597. * Create the column definition for a binary type.
  598. *
  599. * @param \Illuminate\Support\Fluent $column
  600. * @return string
  601. */
  602. protected function typeBinary(Fluent $column)
  603. {
  604. return 'blob';
  605. }
  606. /**
  607. * Create the column definition for a uuid type.
  608. *
  609. * @param \Illuminate\Support\Fluent $column
  610. * @return string
  611. */
  612. protected function typeUuid(Fluent $column)
  613. {
  614. return 'varchar';
  615. }
  616. /**
  617. * Create the column definition for an IP address type.
  618. *
  619. * @param \Illuminate\Support\Fluent $column
  620. * @return string
  621. */
  622. protected function typeIpAddress(Fluent $column)
  623. {
  624. return 'varchar';
  625. }
  626. /**
  627. * Create the column definition for a MAC address type.
  628. *
  629. * @param \Illuminate\Support\Fluent $column
  630. * @return string
  631. */
  632. protected function typeMacAddress(Fluent $column)
  633. {
  634. return 'varchar';
  635. }
  636. /**
  637. * Create the column definition for a spatial Geometry type.
  638. *
  639. * @param \Illuminate\Support\Fluent $column
  640. * @return string
  641. */
  642. public function typeGeometry(Fluent $column)
  643. {
  644. return 'geometry';
  645. }
  646. /**
  647. * Create the column definition for a spatial Point type.
  648. *
  649. * @param \Illuminate\Support\Fluent $column
  650. * @return string
  651. */
  652. public function typePoint(Fluent $column)
  653. {
  654. return 'point';
  655. }
  656. /**
  657. * Create the column definition for a spatial LineString type.
  658. *
  659. * @param \Illuminate\Support\Fluent $column
  660. * @return string
  661. */
  662. public function typeLineString(Fluent $column)
  663. {
  664. return 'linestring';
  665. }
  666. /**
  667. * Create the column definition for a spatial Polygon type.
  668. *
  669. * @param \Illuminate\Support\Fluent $column
  670. * @return string
  671. */
  672. public function typePolygon(Fluent $column)
  673. {
  674. return 'polygon';
  675. }
  676. /**
  677. * Create the column definition for a spatial GeometryCollection type.
  678. *
  679. * @param \Illuminate\Support\Fluent $column
  680. * @return string
  681. */
  682. public function typeGeometryCollection(Fluent $column)
  683. {
  684. return 'geometrycollection';
  685. }
  686. /**
  687. * Create the column definition for a spatial MultiPoint type.
  688. *
  689. * @param \Illuminate\Support\Fluent $column
  690. * @return string
  691. */
  692. public function typeMultiPoint(Fluent $column)
  693. {
  694. return 'multipoint';
  695. }
  696. /**
  697. * Create the column definition for a spatial MultiLineString type.
  698. *
  699. * @param \Illuminate\Support\Fluent $column
  700. * @return string
  701. */
  702. public function typeMultiLineString(Fluent $column)
  703. {
  704. return 'multilinestring';
  705. }
  706. /**
  707. * Create the column definition for a spatial MultiPolygon type.
  708. *
  709. * @param \Illuminate\Support\Fluent $column
  710. * @return string
  711. */
  712. public function typeMultiPolygon(Fluent $column)
  713. {
  714. return 'multipolygon';
  715. }
  716. /**
  717. * Get the SQL for a nullable column modifier.
  718. *
  719. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  720. * @param \Illuminate\Support\Fluent $column
  721. * @return string|null
  722. */
  723. protected function modifyNullable(Blueprint $blueprint, Fluent $column)
  724. {
  725. return $column->nullable ? ' null' : ' not null';
  726. }
  727. /**
  728. * Get the SQL for a default column modifier.
  729. *
  730. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  731. * @param \Illuminate\Support\Fluent $column
  732. * @return string|null
  733. */
  734. protected function modifyDefault(Blueprint $blueprint, Fluent $column)
  735. {
  736. if (! is_null($column->default)) {
  737. return ' default '.$this->getDefaultValue($column->default);
  738. }
  739. }
  740. /**
  741. * Get the SQL for an auto-increment column modifier.
  742. *
  743. * @param \Illuminate\Database\Schema\Blueprint $blueprint
  744. * @param \Illuminate\Support\Fluent $column
  745. * @return string|null
  746. */
  747. protected function modifyIncrement(Blueprint $blueprint, Fluent $column)
  748. {
  749. if (in_array($column->type, $this->serials) && $column->autoIncrement) {
  750. return ' primary key autoincrement';
  751. }
  752. }
  753. }