ISchemaWrapper.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018 Joas Schilling <coding@schilljs.com>
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. *
  7. * @license GNU AGPL version 3 or any later version
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License as
  11. * published by the Free Software Foundation, either version 3 of the
  12. * License, or (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  21. *
  22. */
  23. namespace OCP\DB;
  24. use Doctrine\DBAL\Exception;
  25. use Doctrine\DBAL\Platforms\AbstractPlatform;
  26. /**
  27. * This interface allows to get information about the database schema.
  28. * This is particularly helpful for database migration scripts.
  29. *
  30. * This interface must not be implemented in your application but
  31. * instead can be obtained in your migration scripts with the
  32. * `$schemaClosure` Closure.
  33. *
  34. * @since 13.0.0
  35. */
  36. interface ISchemaWrapper {
  37. /**
  38. * @param string $tableName
  39. *
  40. * @return \Doctrine\DBAL\Schema\Table
  41. * @throws \Doctrine\DBAL\Schema\SchemaException
  42. * @since 13.0.0
  43. */
  44. public function getTable($tableName);
  45. /**
  46. * Does this schema have a table with the given name?
  47. *
  48. * @param string $tableName Prefix is automatically prepended
  49. *
  50. * @return boolean
  51. * @since 13.0.0
  52. */
  53. public function hasTable($tableName);
  54. /**
  55. * Creates a new table.
  56. *
  57. * @param string $tableName Prefix is automatically prepended
  58. * @return \Doctrine\DBAL\Schema\Table
  59. * @since 13.0.0
  60. */
  61. public function createTable($tableName);
  62. /**
  63. * Drops a table from the schema.
  64. *
  65. * @param string $tableName Prefix is automatically prepended
  66. * @return \Doctrine\DBAL\Schema\Schema
  67. * @since 13.0.0
  68. */
  69. public function dropTable($tableName);
  70. /**
  71. * Gets all tables of this schema.
  72. *
  73. * @return \Doctrine\DBAL\Schema\Table[]
  74. * @since 13.0.0
  75. */
  76. public function getTables();
  77. /**
  78. * Gets all table names, prefixed with table prefix
  79. *
  80. * @return array
  81. * @since 13.0.0
  82. */
  83. public function getTableNames();
  84. /**
  85. * Gets all table names
  86. *
  87. * @return array
  88. * @since 13.0.0
  89. */
  90. public function getTableNamesWithoutPrefix();
  91. /**
  92. * Gets the DatabasePlatform for the database.
  93. *
  94. * @return AbstractPlatform
  95. *
  96. * @throws Exception
  97. * @since 23.0.0
  98. */
  99. public function getDatabasePlatform();
  100. }