| 1 | <?php |
| 2 | |
| 3 | namespace Wikimedia\Rdbms; |
| 4 | |
| 5 | /** |
| 6 | * Interface SchemaBuilder that gets a definition and produces SQL based on RDBMS |
| 7 | * |
| 8 | * @experimental |
| 9 | * @unstable |
| 10 | */ |
| 11 | interface SchemaBuilder { |
| 12 | |
| 13 | /** |
| 14 | * An example of $schema value: |
| 15 | * [ |
| 16 | * 'name' => 'actor', |
| 17 | * 'columns' => [ |
| 18 | * [ 'actor_id', 'bigint', [ 'Unsigned' => true, 'Notnull' => true ] ], |
| 19 | * [ 'actor_user', 'integer', [ 'Unsigned' => true ] ], |
| 20 | * [ 'actor_name', 'string', [ 'Length' => 255, 'Notnull' => true ] ], |
| 21 | * ], |
| 22 | * 'indexes' => [ |
| 23 | * [ 'actor_user', [ 'actor_user' ], 'unique' => true ], |
| 24 | * [ 'actor_name', [ 'actor_name' ], 'unique' => true ] |
| 25 | * ], |
| 26 | * 'pk' => [ 'actor_id' ] |
| 27 | * ], |
| 28 | * @param array $schema |
| 29 | * @return void |
| 30 | */ |
| 31 | public function addTable( array $schema ); |
| 32 | |
| 33 | /** |
| 34 | * @return string[] SQLs to run |
| 35 | */ |
| 36 | public function getSql(); |
| 37 | } |