Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/ColumnSchemaBuilder.php → src/Column.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,30 @@

namespace Yiisoft\Db\Sqlite;

use Yiisoft\Db\Schema\AbstractColumnSchemaBuilder;
use Yiisoft\Db\Schema\Builder\AbstractColumn;

/**
* It's a utility that provides a convenient way to create column schema for use with {@see Schema} for SQLite Server.
* It's a utility that provides a convenient way to create column schema for use with {@see `\Yiisoft\Db\SQLite\Schema`}
* for SQLite.
*
* It provides methods for specifying the properties of a column, such as its type, size, default value, and whether it
* is nullable or not. It also provides a method for creating a column schema based on the specified properties.
*
* For example, the following code creates a column schema for an integer column:
*
* ```php
* $column = (new ColumnSchemaBuilder(SchemaInterface::TYPE_INTEGER))->notNull()->defaultValue(0);
* $column = (new Column(SchemaInterface::TYPE_INTEGER))->notNull()->defaultValue(0);
* ```
*
* Provides a fluent interface, which means that the methods can be chained together to create a column schema with
* many properties in a single line of code.
*/
final class ColumnSchemaBuilder extends AbstractColumnSchemaBuilder
final class Column extends AbstractColumn
{
/**
* Builds the unsigned string for column. Defaults to unsupported.
*
* @return string A string containing UNSIGNED keyword.
* @return string a string containing UNSIGNED keyword.
*/
protected function buildUnsignedString(): string
{
Expand Down
4 changes: 2 additions & 2 deletions src/DDLQueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Yiisoft\Db\Exception\NotSupportedException;
use Yiisoft\Db\QueryBuilder\AbstractDDLQueryBuilder;
use Yiisoft\Db\QueryBuilder\QueryBuilderInterface;
use Yiisoft\Db\Schema\ColumnSchemaBuilderInterface;
use Yiisoft\Db\Schema\Builder\ColumnInterface;
use Yiisoft\Db\Schema\QuoterInterface;
use Yiisoft\Db\Schema\SchemaInterface;

Expand Down Expand Up @@ -92,7 +92,7 @@ public function addUnique(string $name, string $table, array|string $columns): s
/**
* @throws NotSupportedException SQLite doesn't support this method.
*/
public function alterColumn(string $table, string $column, ColumnSchemaBuilderInterface|string $type): string
public function alterColumn(string $table, string $column, ColumnInterface|string $type): string
{
throw new NotSupportedException(__METHOD__ . ' is not supported by SQLite.');
}
Expand Down
14 changes: 6 additions & 8 deletions src/Schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use Yiisoft\Db\Expression\Expression;
use Yiisoft\Db\Helper\ArrayHelper;
use Yiisoft\Db\Schema\AbstractSchema;
use Yiisoft\Db\Schema\ColumnSchemaBuilderInterface;
use Yiisoft\Db\Schema\Builder\ColumnInterface;
use Yiisoft\Db\Schema\ColumnSchemaInterface;
use Yiisoft\Db\Schema\TableSchemaInterface;

Expand Down Expand Up @@ -116,6 +116,11 @@ final class Schema extends AbstractSchema
'enum' => self::TYPE_STRING,
];

public function createColumn(string $type, array|int|string $length = null): ColumnInterface
{
return new Column($type, $length);
}

/**
* Returns all table names in the database.
*
Expand Down Expand Up @@ -334,13 +339,6 @@ protected function loadTableDefaultValues(string $tableName): array
throw new NotSupportedException('SQLite does not support default value constraints.');
}

public function createColumnSchemaBuilder(
string $type,
array|int|string $length = null
): ColumnSchemaBuilderInterface {
return new ColumnSchemaBuilder($type, $length);
}

/**
* Collects the table column metadata.
*
Expand Down