SQLiteBuilder
class SQLiteBuilder extends Builder
Traits
Properties
| static protected array | $macros | The registered string macros. |
from Macroable |
| protected Connection | $connection | The database connection instance. |
from Builder |
| SQLiteGrammar | $grammar | ||
| protected Connection, string, null|Blueprint | $resolver | The Blueprint resolver callback. |
from Builder |
| static int|null | $defaultStringLength | The default string length for migrations. |
from Builder |
| static int|null | $defaultTimePrecision | The default time precision for migrations. |
from Builder |
| static string | $defaultMorphKeyType | The default relationship morph key type. |
from Builder |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Set the default string length for migrations.
Set the default time precision for migrations.
Set the default morph key type for migrations.
Create a database in the schema.
Drop a database from the schema if the database exists.
Get the tables that belong to the connection.
Get the names of the tables that belong to the connection.
Get the views that belong to the connection.
Get the user-defined types that belong to the connection.
Determine if the given table has a given column.
Determine if the given table has given columns.
Execute a table builder callback if the given table has a given column.
Execute a table builder callback if the given table doesn't have a given column.
Execute a table builder callback if the given table has a given index.
Execute a table builder callback if the given table doesn't have a given index.
Get the data type for the given column name.
Get the columns for a given table.
Determine if the given table has a given index.
Determine if the table has a given foreign key.
Drop columns from a table schema.
Drop all tables from the database.
Drop all views from the database.
Disable foreign key constraints during the execution of a callback.
Create the vector extension on the schema if it does not exist.
Create a new extension on the schema if it does not exist.
Create a new command set with a Closure.
Get the names of current schemas for the connection.
Parse the given database object reference and extract the schema and table.
Validate the database name for filesystem management.
Get the value for the given pragma name or set the given value.
Empty the database file.
Details
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
in
Builder at line 55
__construct(Connection $connection)
Create a new database Schema manager.
in
Builder at line 67
static void
defaultStringLength(int $length)
Set the default string length for migrations.
Boot-only. The length persists in a static property for the worker lifetime and applies to every Blueprint::string() across all coroutines.
in
Builder at line 78
static void
defaultTimePrecision(int|null $precision)
Set the default time precision for migrations.
Boot-only. The precision persists in a static property for the worker lifetime and applies to every time/datetime column across all coroutines.
in
Builder at line 91
static void
defaultMorphKeyType(string $type)
Set the default morph key type for migrations.
Boot-only. The type persists in a static property for the worker lifetime and applies to every morph() column across all coroutines.
in
Builder at line 103
static void
flushState()
Flush all static state.
in
Builder at line 116
static void
morphUsingUuids()
Set the default morph key type for migrations to UUIDs.
Boot-only. Sets the worker-wide morph type via defaultMorphKeyType().
in
Builder at line 126
static void
morphUsingUlids()
Set the default morph key type for migrations to ULIDs.
Boot-only. Sets the worker-wide morph type via defaultMorphKeyType().
at line 23
bool
createDatabase(string $name)
Create a database in the schema.
at line 34
bool
dropDatabaseIfExists(string $name)
Drop a database from the schema if the database exists.
in
Builder at line 156
array
getSchemas()
Get the schemas that belong to the connection.
in
Builder at line 166
bool
hasTable(string $table)
Determine if the given table exists.
in
Builder at line 188
bool
hasView(string $view)
Determine if the given view exists.
at line 54
array
getTables(array|string|null $schema = null)
Get the tables that belong to the connection.
in
Builder at line 221
array
getTableListing(array|string|null $schema = null, bool $schemaQualified = true)
Get the names of the tables that belong to the connection.
at line 84
array
getViews(array|string|null $schema = null)
Get the views that belong to the connection.
in
Builder at line 246
array
getTypes(array|string|null $schema = null)
Get the user-defined types that belong to the connection.
in
Builder at line 256
bool
hasColumn(string $table, string $column)
Determine if the given table has a given column.
in
Builder at line 269
bool
hasColumns(string $table, array $columns)
Determine if the given table has given columns.
in
Builder at line 285
void
whenTableHasColumn(string $table, string $column, Closure $callback)
Execute a table builder callback if the given table has a given column.
in
Builder at line 295
void
whenTableDoesntHaveColumn(string $table, string $column, Closure $callback)
Execute a table builder callback if the given table doesn't have a given column.
in
Builder at line 305
void
whenTableHasIndex(string $table, array|string $index, Closure $callback, string|null $type = null)
Execute a table builder callback if the given table has a given index.
in
Builder at line 315
void
whenTableDoesntHaveIndex(string $table, array|string $index, Closure $callback, string|null $type = null)
Execute a table builder callback if the given table doesn't have a given index.
in
Builder at line 325
string
getColumnType(string $table, string $column, bool $fullDefinition = false)
Get the data type for the given column name.
in
Builder at line 343
array
getColumnListing(string $table)
Get the column listing for a given table.
at line 100
array
getColumns(string $table)
Get the columns for a given table.
in
Builder at line 371
array
getIndexes(string $table)
Get the indexes for a given table.
in
Builder at line 389
array
getIndexListing(string $table)
Get the names of the indexes for a given table.
in
Builder at line 397
bool
hasIndex(string $table, array|string $index, string|null $type = null)
Determine if the given table has a given index.
in
Builder at line 418
bool
hasForeignKey(string $table, array|string $foreignKey)
Determine if the table has a given foreign key.
in
Builder at line 432
array
getForeignKeys(string $table)
Get the foreign keys for a given table.
in
Builder at line 456
void
create(string $table, Closure $callback)
Create a new table on the schema.
in
Builder at line 468
void
drop(string $table)
Drop a table from the schema.
in
Builder at line 478
void
dropIfExists(string $table)
Drop a table from the schema if it exists.
in
Builder at line 490
void
dropColumns(string $table, array|string $columns)
Drop columns from a table schema.
at line 116
void
dropAllTables()
Drop all tables from the database.
at line 141
void
dropAllViews()
Drop all views from the database.
in
Builder at line 522
void
dropAllTypes()
Drop all types from the database.
in
Builder at line 530
void
rename(string $from, string $to)
Rename a table on the schema.
in
Builder at line 540
bool
enableForeignKeyConstraints()
Enable foreign key constraints.
in
Builder at line 550
bool
disableForeignKeyConstraints()
Disable foreign key constraints.
in
Builder at line 560
mixed
withoutForeignKeyConstraints(Closure $callback)
Disable foreign key constraints during the execution of a callback.
in
Builder at line 574
void
ensureVectorExtensionExists(string|null $schema = null)
Create the vector extension on the schema if it does not exist.
in
Builder at line 582
void
ensureExtensionExists(string $name, string|null $schema = null)
Create a new extension on the schema if it does not exist.
in
Builder at line 599
protected void
build(Blueprint $blueprint)
Execute the blueprint to build / modify the table.
in
Builder at line 607
protected Blueprint
createBlueprint(string $table, Closure|null $callback = null)
Create a new command set with a Closure.
at line 180
array|null
getCurrentSchemaListing()
Get the names of current schemas for the connection.
in
Builder at line 631
string|null
getCurrentSchemaName()
Get the default schema name for the connection.
in
Builder at line 639
array
parseSchemaAndTable(string $reference, bool|string|null $withDefaultSchema = null)
Parse the given database object reference and extract the schema and table.
in
Builder at line 664
Connection
getConnection()
Get the database connection instance.
in
Builder at line 674
void
blueprintResolver(Closure $resolver)
Set the Schema Blueprint resolver callback.
at line 45
protected void
validateDatabasePath(string $name)
Validate the database name for filesystem management.
at line 158
mixed
pragma(string $key, mixed $value = null)
Get the value for the given pragma name or set the given value.
at line 168
void
refreshDatabaseFile(string|null $path = null)
Empty the database file.