Migration.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548
  1. <?php
  2. /**
  3. * @link http://www.yiiframework.com/
  4. * @copyright Copyright (c) 2008 Yii Software LLC
  5. * @license http://www.yiiframework.com/license/
  6. */
  7. namespace yii\db;
  8. use yii\base\Component;
  9. use yii\di\Instance;
  10. /**
  11. * Migration is the base class for representing a database migration.
  12. *
  13. * Migration is designed to be used together with the "yii migrate" command.
  14. *
  15. * Each child class of Migration represents an individual database migration which
  16. * is identified by the child class name.
  17. *
  18. * Within each migration, the [[up()]] method should be overridden to contain the logic
  19. * for "upgrading" the database; while the [[down()]] method for the "downgrading"
  20. * logic. The "yii migrate" command manages all available migrations in an application.
  21. *
  22. * If the database supports transactions, you may also override [[safeUp()]] and
  23. * [[safeDown()]] so that if anything wrong happens during the upgrading or downgrading,
  24. * the whole migration can be reverted in a whole.
  25. *
  26. * Note that some DB queries in some DBMS cannot be put into a transaction. For some examples,
  27. * please refer to [implicit commit](http://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html). If this is the case,
  28. * you should still implement `up()` and `down()`, instead.
  29. *
  30. * Migration provides a set of convenient methods for manipulating database data and schema.
  31. * For example, the [[insert()]] method can be used to easily insert a row of data into
  32. * a database table; the [[createTable()]] method can be used to create a database table.
  33. * Compared with the same methods in [[Command]], these methods will display extra
  34. * information showing the method parameters and execution time, which may be useful when
  35. * applying migrations.
  36. *
  37. * For more details and usage information on Migration, see the [guide article on Migration](guide:db-migrations).
  38. *
  39. * @author Qiang Xue <qiang.xue@gmail.com>
  40. * @since 2.0
  41. */
  42. class Migration extends Component implements MigrationInterface
  43. {
  44. use SchemaBuilderTrait;
  45. /**
  46. * @var Connection|array|string the DB connection object or the application component ID of the DB connection
  47. * that this migration should work with. Starting from version 2.0.2, this can also be a configuration array
  48. * for creating the object.
  49. *
  50. * Note that when a Migration object is created by the `migrate` command, this property will be overwritten
  51. * by the command. If you do not want to use the DB connection provided by the command, you may override
  52. * the [[init()]] method like the following:
  53. *
  54. * ```php
  55. * public function init()
  56. * {
  57. * $this->db = 'db2';
  58. * parent::init();
  59. * }
  60. * ```
  61. */
  62. public $db = 'db';
  63. /**
  64. * Initializes the migration.
  65. * This method will set [[db]] to be the 'db' application component, if it is `null`.
  66. */
  67. public function init()
  68. {
  69. parent::init();
  70. $this->db = Instance::ensure($this->db, Connection::className());
  71. $this->db->getSchema()->refresh();
  72. $this->db->enableSlaves = false;
  73. }
  74. /**
  75. * @inheritdoc
  76. * @since 2.0.6
  77. */
  78. protected function getDb()
  79. {
  80. return $this->db;
  81. }
  82. /**
  83. * This method contains the logic to be executed when applying this migration.
  84. * Child classes may override this method to provide actual migration logic.
  85. * @return bool return a false value to indicate the migration fails
  86. * and should not proceed further. All other return values mean the migration succeeds.
  87. */
  88. public function up()
  89. {
  90. $transaction = $this->db->beginTransaction();
  91. try {
  92. if ($this->safeUp() === false) {
  93. $transaction->rollBack();
  94. return false;
  95. }
  96. $transaction->commit();
  97. } catch (\Exception $e) {
  98. $this->printException($e);
  99. $transaction->rollBack();
  100. return false;
  101. } catch (\Throwable $e) {
  102. $this->printException($e);
  103. $transaction->rollBack();
  104. return false;
  105. }
  106. return null;
  107. }
  108. /**
  109. * This method contains the logic to be executed when removing this migration.
  110. * The default implementation throws an exception indicating the migration cannot be removed.
  111. * Child classes may override this method if the corresponding migrations can be removed.
  112. * @return bool return a false value to indicate the migration fails
  113. * and should not proceed further. All other return values mean the migration succeeds.
  114. */
  115. public function down()
  116. {
  117. $transaction = $this->db->beginTransaction();
  118. try {
  119. if ($this->safeDown() === false) {
  120. $transaction->rollBack();
  121. return false;
  122. }
  123. $transaction->commit();
  124. } catch (\Exception $e) {
  125. $this->printException($e);
  126. $transaction->rollBack();
  127. return false;
  128. } catch (\Throwable $e) {
  129. $this->printException($e);
  130. $transaction->rollBack();
  131. return false;
  132. }
  133. return null;
  134. }
  135. /**
  136. * @param \Throwable|\Exception $e
  137. */
  138. private function printException($e)
  139. {
  140. echo 'Exception: ' . $e->getMessage() . ' (' . $e->getFile() . ':' . $e->getLine() . ")\n";
  141. echo $e->getTraceAsString() . "\n";
  142. }
  143. /**
  144. * This method contains the logic to be executed when applying this migration.
  145. * This method differs from [[up()]] in that the DB logic implemented here will
  146. * be enclosed within a DB transaction.
  147. * Child classes may implement this method instead of [[up()]] if the DB logic
  148. * needs to be within a transaction.
  149. *
  150. * Note: Not all DBMS support transactions. And some DB queries cannot be put into a transaction. For some examples,
  151. * please refer to [implicit commit](http://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html). If this is the case,
  152. * you should still implement `up()` and `down()`, instead.
  153. *
  154. * @return bool return a false value to indicate the migration fails
  155. * and should not proceed further. All other return values mean the migration succeeds.
  156. */
  157. public function safeUp()
  158. {
  159. }
  160. /**
  161. * This method contains the logic to be executed when removing this migration.
  162. * This method differs from [[down()]] in that the DB logic implemented here will
  163. * be enclosed within a DB transaction.
  164. * Child classes may implement this method instead of [[down()]] if the DB logic
  165. * needs to be within a transaction.
  166. *
  167. * Note: Not all DBMS support transactions. And some DB queries cannot be put into a transaction. For some examples,
  168. * please refer to [implicit commit](http://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html). If this is the case,
  169. * you should still implement `up()` and `down()`, instead.
  170. *
  171. * @return bool return a false value to indicate the migration fails
  172. * and should not proceed further. All other return values mean the migration succeeds.
  173. */
  174. public function safeDown()
  175. {
  176. }
  177. /**
  178. * Executes a SQL statement.
  179. * This method executes the specified SQL statement using [[db]].
  180. * @param string $sql the SQL statement to be executed
  181. * @param array $params input parameters (name => value) for the SQL execution.
  182. * See [[Command::execute()]] for more details.
  183. */
  184. public function execute($sql, $params = [])
  185. {
  186. echo " > execute SQL: $sql ...";
  187. $time = microtime(true);
  188. $this->db->createCommand($sql)->bindValues($params)->execute();
  189. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  190. }
  191. /**
  192. * Creates and executes an INSERT SQL statement.
  193. * The method will properly escape the column names, and bind the values to be inserted.
  194. * @param string $table the table that new rows will be inserted into.
  195. * @param array $columns the column data (name => value) to be inserted into the table.
  196. */
  197. public function insert($table, $columns)
  198. {
  199. echo " > insert into $table ...";
  200. $time = microtime(true);
  201. $this->db->createCommand()->insert($table, $columns)->execute();
  202. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  203. }
  204. /**
  205. * Creates and executes an batch INSERT SQL statement.
  206. * The method will properly escape the column names, and bind the values to be inserted.
  207. * @param string $table the table that new rows will be inserted into.
  208. * @param array $columns the column names.
  209. * @param array $rows the rows to be batch inserted into the table
  210. */
  211. public function batchInsert($table, $columns, $rows)
  212. {
  213. echo " > insert into $table ...";
  214. $time = microtime(true);
  215. $this->db->createCommand()->batchInsert($table, $columns, $rows)->execute();
  216. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  217. }
  218. /**
  219. * Creates and executes an UPDATE SQL statement.
  220. * The method will properly escape the column names and bind the values to be updated.
  221. * @param string $table the table to be updated.
  222. * @param array $columns the column data (name => value) to be updated.
  223. * @param array|string $condition the conditions that will be put in the WHERE part. Please
  224. * refer to [[Query::where()]] on how to specify conditions.
  225. * @param array $params the parameters to be bound to the query.
  226. */
  227. public function update($table, $columns, $condition = '', $params = [])
  228. {
  229. echo " > update $table ...";
  230. $time = microtime(true);
  231. $this->db->createCommand()->update($table, $columns, $condition, $params)->execute();
  232. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  233. }
  234. /**
  235. * Creates and executes a DELETE SQL statement.
  236. * @param string $table the table where the data will be deleted from.
  237. * @param array|string $condition the conditions that will be put in the WHERE part. Please
  238. * refer to [[Query::where()]] on how to specify conditions.
  239. * @param array $params the parameters to be bound to the query.
  240. */
  241. public function delete($table, $condition = '', $params = [])
  242. {
  243. echo " > delete from $table ...";
  244. $time = microtime(true);
  245. $this->db->createCommand()->delete($table, $condition, $params)->execute();
  246. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  247. }
  248. /**
  249. * Builds and executes a SQL statement for creating a new DB table.
  250. *
  251. * The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'),
  252. * where name stands for a column name which will be properly quoted by the method, and definition
  253. * stands for the column type which can contain an abstract DB type.
  254. *
  255. * The [[QueryBuilder::getColumnType()]] method will be invoked to convert any abstract type into a physical one.
  256. *
  257. * If a column is specified with definition only (e.g. 'PRIMARY KEY (name, type)'), it will be directly
  258. * put into the generated SQL.
  259. *
  260. * @param string $table the name of the table to be created. The name will be properly quoted by the method.
  261. * @param array $columns the columns (name => definition) in the new table.
  262. * @param string $options additional SQL fragment that will be appended to the generated SQL.
  263. */
  264. public function createTable($table, $columns, $options = null)
  265. {
  266. echo " > create table $table ...";
  267. $time = microtime(true);
  268. $this->db->createCommand()->createTable($table, $columns, $options)->execute();
  269. foreach ($columns as $column => $type) {
  270. if ($type instanceof ColumnSchemaBuilder && $type->comment !== null) {
  271. $this->db->createCommand()->addCommentOnColumn($table, $column, $type->comment)->execute();
  272. }
  273. }
  274. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  275. }
  276. /**
  277. * Builds and executes a SQL statement for renaming a DB table.
  278. * @param string $table the table to be renamed. The name will be properly quoted by the method.
  279. * @param string $newName the new table name. The name will be properly quoted by the method.
  280. */
  281. public function renameTable($table, $newName)
  282. {
  283. echo " > rename table $table to $newName ...";
  284. $time = microtime(true);
  285. $this->db->createCommand()->renameTable($table, $newName)->execute();
  286. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  287. }
  288. /**
  289. * Builds and executes a SQL statement for dropping a DB table.
  290. * @param string $table the table to be dropped. The name will be properly quoted by the method.
  291. */
  292. public function dropTable($table)
  293. {
  294. echo " > drop table $table ...";
  295. $time = microtime(true);
  296. $this->db->createCommand()->dropTable($table)->execute();
  297. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  298. }
  299. /**
  300. * Builds and executes a SQL statement for truncating a DB table.
  301. * @param string $table the table to be truncated. The name will be properly quoted by the method.
  302. */
  303. public function truncateTable($table)
  304. {
  305. echo " > truncate table $table ...";
  306. $time = microtime(true);
  307. $this->db->createCommand()->truncateTable($table)->execute();
  308. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  309. }
  310. /**
  311. * Builds and executes a SQL statement for adding a new DB column.
  312. * @param string $table the table that the new column will be added to. The table name will be properly quoted by the method.
  313. * @param string $column the name of the new column. The name will be properly quoted by the method.
  314. * @param string $type the column type. The [[QueryBuilder::getColumnType()]] method will be invoked to convert abstract column type (if any)
  315. * into the physical one. Anything that is not recognized as abstract type will be kept in the generated SQL.
  316. * For example, 'string' will be turned into 'varchar(255)', while 'string not null' will become 'varchar(255) not null'.
  317. */
  318. public function addColumn($table, $column, $type)
  319. {
  320. echo " > add column $column $type to table $table ...";
  321. $time = microtime(true);
  322. $this->db->createCommand()->addColumn($table, $column, $type)->execute();
  323. if ($type instanceof ColumnSchemaBuilder && $type->comment !== null) {
  324. $this->db->createCommand()->addCommentOnColumn($table, $column, $type->comment)->execute();
  325. }
  326. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  327. }
  328. /**
  329. * Builds and executes a SQL statement for dropping a DB column.
  330. * @param string $table the table whose column is to be dropped. The name will be properly quoted by the method.
  331. * @param string $column the name of the column to be dropped. The name will be properly quoted by the method.
  332. */
  333. public function dropColumn($table, $column)
  334. {
  335. echo " > drop column $column from table $table ...";
  336. $time = microtime(true);
  337. $this->db->createCommand()->dropColumn($table, $column)->execute();
  338. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  339. }
  340. /**
  341. * Builds and executes a SQL statement for renaming a column.
  342. * @param string $table the table whose column is to be renamed. The name will be properly quoted by the method.
  343. * @param string $name the old name of the column. The name will be properly quoted by the method.
  344. * @param string $newName the new name of the column. The name will be properly quoted by the method.
  345. */
  346. public function renameColumn($table, $name, $newName)
  347. {
  348. echo " > rename column $name in table $table to $newName ...";
  349. $time = microtime(true);
  350. $this->db->createCommand()->renameColumn($table, $name, $newName)->execute();
  351. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  352. }
  353. /**
  354. * Builds and executes a SQL statement for changing the definition of a column.
  355. * @param string $table the table whose column is to be changed. The table name will be properly quoted by the method.
  356. * @param string $column the name of the column to be changed. The name will be properly quoted by the method.
  357. * @param string $type the new column type. The [[QueryBuilder::getColumnType()]] method will be invoked to convert abstract column type (if any)
  358. * into the physical one. Anything that is not recognized as abstract type will be kept in the generated SQL.
  359. * For example, 'string' will be turned into 'varchar(255)', while 'string not null' will become 'varchar(255) not null'.
  360. */
  361. public function alterColumn($table, $column, $type)
  362. {
  363. echo " > alter column $column in table $table to $type ...";
  364. $time = microtime(true);
  365. $this->db->createCommand()->alterColumn($table, $column, $type)->execute();
  366. if ($type instanceof ColumnSchemaBuilder && $type->comment !== null) {
  367. $this->db->createCommand()->addCommentOnColumn($table, $column, $type->comment)->execute();
  368. }
  369. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  370. }
  371. /**
  372. * Builds and executes a SQL statement for creating a primary key.
  373. * The method will properly quote the table and column names.
  374. * @param string $name the name of the primary key constraint.
  375. * @param string $table the table that the primary key constraint will be added to.
  376. * @param string|array $columns comma separated string or array of columns that the primary key will consist of.
  377. */
  378. public function addPrimaryKey($name, $table, $columns)
  379. {
  380. echo " > add primary key $name on $table (" . (is_array($columns) ? implode(',', $columns) : $columns) . ') ...';
  381. $time = microtime(true);
  382. $this->db->createCommand()->addPrimaryKey($name, $table, $columns)->execute();
  383. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  384. }
  385. /**
  386. * Builds and executes a SQL statement for dropping a primary key.
  387. * @param string $name the name of the primary key constraint to be removed.
  388. * @param string $table the table that the primary key constraint will be removed from.
  389. */
  390. public function dropPrimaryKey($name, $table)
  391. {
  392. echo " > drop primary key $name ...";
  393. $time = microtime(true);
  394. $this->db->createCommand()->dropPrimaryKey($name, $table)->execute();
  395. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  396. }
  397. /**
  398. * Builds a SQL statement for adding a foreign key constraint to an existing table.
  399. * The method will properly quote the table and column names.
  400. * @param string $name the name of the foreign key constraint.
  401. * @param string $table the table that the foreign key constraint will be added to.
  402. * @param string|array $columns the name of the column to that the constraint will be added on. If there are multiple columns, separate them with commas or use an array.
  403. * @param string $refTable the table that the foreign key references to.
  404. * @param string|array $refColumns the name of the column that the foreign key references to. If there are multiple columns, separate them with commas or use an array.
  405. * @param string $delete the ON DELETE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
  406. * @param string $update the ON UPDATE option. Most DBMS support these options: RESTRICT, CASCADE, NO ACTION, SET DEFAULT, SET NULL
  407. */
  408. public function addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete = null, $update = null)
  409. {
  410. echo " > add foreign key $name: $table (" . implode(',', (array) $columns) . ") references $refTable (" . implode(',', (array) $refColumns) . ') ...';
  411. $time = microtime(true);
  412. $this->db->createCommand()->addForeignKey($name, $table, $columns, $refTable, $refColumns, $delete, $update)->execute();
  413. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  414. }
  415. /**
  416. * Builds a SQL statement for dropping a foreign key constraint.
  417. * @param string $name the name of the foreign key constraint to be dropped. The name will be properly quoted by the method.
  418. * @param string $table the table whose foreign is to be dropped. The name will be properly quoted by the method.
  419. */
  420. public function dropForeignKey($name, $table)
  421. {
  422. echo " > drop foreign key $name from table $table ...";
  423. $time = microtime(true);
  424. $this->db->createCommand()->dropForeignKey($name, $table)->execute();
  425. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  426. }
  427. /**
  428. * Builds and executes a SQL statement for creating a new index.
  429. * @param string $name the name of the index. The name will be properly quoted by the method.
  430. * @param string $table the table that the new index will be created for. The table name will be properly quoted by the method.
  431. * @param string|array $columns the column(s) that should be included in the index. If there are multiple columns, please separate them
  432. * by commas or use an array. Each column name will be properly quoted by the method. Quoting will be skipped for column names that
  433. * include a left parenthesis "(".
  434. * @param bool $unique whether to add UNIQUE constraint on the created index.
  435. */
  436. public function createIndex($name, $table, $columns, $unique = false)
  437. {
  438. echo ' > create' . ($unique ? ' unique' : '') . " index $name on $table (" . implode(',', (array) $columns) . ') ...';
  439. $time = microtime(true);
  440. $this->db->createCommand()->createIndex($name, $table, $columns, $unique)->execute();
  441. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  442. }
  443. /**
  444. * Builds and executes a SQL statement for dropping an index.
  445. * @param string $name the name of the index to be dropped. The name will be properly quoted by the method.
  446. * @param string $table the table whose index is to be dropped. The name will be properly quoted by the method.
  447. */
  448. public function dropIndex($name, $table)
  449. {
  450. echo " > drop index $name on $table ...";
  451. $time = microtime(true);
  452. $this->db->createCommand()->dropIndex($name, $table)->execute();
  453. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  454. }
  455. /**
  456. * Builds and execute a SQL statement for adding comment to column
  457. *
  458. * @param string $table the table whose column is to be commented. The table name will be properly quoted by the method.
  459. * @param string $column the name of the column to be commented. The column name will be properly quoted by the method.
  460. * @param string $comment the text of the comment to be added. The comment will be properly quoted by the method.
  461. * @since 2.0.8
  462. */
  463. public function addCommentOnColumn($table, $column, $comment)
  464. {
  465. echo " > add comment on column $column ...";
  466. $time = microtime(true);
  467. $this->db->createCommand()->addCommentOnColumn($table, $column, $comment)->execute();
  468. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  469. }
  470. /**
  471. * Builds a SQL statement for adding comment to table
  472. *
  473. * @param string $table the table whose column is to be commented. The table name will be properly quoted by the method.
  474. * @param string $comment the text of the comment to be added. The comment will be properly quoted by the method.
  475. * @since 2.0.8
  476. */
  477. public function addCommentOnTable($table, $comment)
  478. {
  479. echo " > add comment on table $table ...";
  480. $time = microtime(true);
  481. $this->db->createCommand()->addCommentOnTable($table, $comment)->execute();
  482. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  483. }
  484. /**
  485. * Builds and execute a SQL statement for dropping comment from column
  486. *
  487. * @param string $table the table whose column is to be commented. The table name will be properly quoted by the method.
  488. * @param string $column the name of the column to be commented. The column name will be properly quoted by the method.
  489. * @since 2.0.8
  490. */
  491. public function dropCommentFromColumn($table, $column)
  492. {
  493. echo " > drop comment from column $column ...";
  494. $time = microtime(true);
  495. $this->db->createCommand()->dropCommentFromColumn($table, $column)->execute();
  496. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  497. }
  498. /**
  499. * Builds a SQL statement for dropping comment from table
  500. *
  501. * @param string $table the table whose column is to be commented. The table name will be properly quoted by the method.
  502. * @since 2.0.8
  503. */
  504. public function dropCommentFromTable($table)
  505. {
  506. echo " > drop comment from table $table ...";
  507. $time = microtime(true);
  508. $this->db->createCommand()->dropCommentFromTable($table)->execute();
  509. echo ' done (time: ' . sprintf('%.3f', microtime(true) - $time) . "s)\n";
  510. }
  511. }