-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathLibsqlSchemaGrammar.php
More file actions
46 lines (36 loc) · 1.42 KB
/
LibsqlSchemaGrammar.php
File metadata and controls
46 lines (36 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
namespace Libsql\Laravel\Database;
use Illuminate\Database\Schema\Grammars\SQLiteGrammar;
use Illuminate\Support\Fluent;
class LibsqlSchemaGrammar extends SQLiteGrammar
{
public function compileDropAllIndexes(): string
{
return "SELECT 'DROP INDEX IF EXISTS \"' || name || '\";' FROM sqlite_schema WHERE type = 'index' AND name NOT LIKE 'sqlite_%'";
}
public function compileDropAllTables($schema = null): string
{
return "SELECT 'DROP TABLE IF EXISTS \"' || name || '\";' FROM sqlite_schema WHERE type = 'table' AND name NOT LIKE 'sqlite_%'";
}
public function compileDropAllTriggers(): string
{
return "SELECT 'DROP TRIGGER IF EXISTS \"' || name || '\";' FROM sqlite_schema WHERE type = 'trigger' AND name NOT LIKE 'sqlite_%'";
}
public function compileDropAllViews($schema = null): string
{
return "SELECT 'DROP VIEW IF EXISTS \"' || name || '\";' FROM sqlite_schema WHERE type = 'view'";
}
#[\Override]
public function wrap($value, $prefixAlias = false): string
{
return str_replace('"', '\'', parent::wrap($value));
}
public function typeVector(Fluent $column): string
{
if (isset($column->dimensions) && $column->dimensions !== '') {
return "F32_BLOB({$column->dimensions})";
}
throw new \RuntimeException('Dimension must be set for vector embedding');
}
}