fixing database connections
This commit is contained in:
@@ -28,6 +28,15 @@
|
||||
editor.addEventListener("trix-file-accept", (e) => {
|
||||
e.preventDefault();
|
||||
})
|
||||
|
||||
editor.addEventListener("trix-before-initialize", (e) => {
|
||||
Trix.config.blockAttributes.heading1.tagName = 'h2';
|
||||
const { toolbarElement } = e.target
|
||||
const h1Button = toolbarElement.querySelector("[data-trix-attribute=heading1]")
|
||||
h1Button.insertAdjacentHTML("afterend", `<button style="text-indent: initial;padding: 14px 10px !important;" type="button" class="trix-button trix-button--icon" data-trix-attribute="heading3" title="Heading 3" tabindex="-1" data-trix-active="">H3</button>`)
|
||||
})
|
||||
|
||||
|
||||
})
|
||||
// onDestroy(() => {
|
||||
// editor.removeEventListener("trix-before-initialize")
|
||||
@@ -35,7 +44,13 @@
|
||||
|
||||
|
||||
Trix.config.blockAttributes.default.breakOnReturn = false
|
||||
console.log(Trix.config)
|
||||
Trix.config.blockAttributes.heading3 = {
|
||||
tagName: 'h3',
|
||||
terminal: true,
|
||||
breakOnReturn: true,
|
||||
group: false
|
||||
}
|
||||
// console.log(Trix.config)
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
@@ -7,11 +7,16 @@
|
||||
|
||||
.cm-content{
|
||||
background-color: var(--p10);
|
||||
color: var(--p100);
|
||||
}
|
||||
}
|
||||
|
||||
.cm-content{
|
||||
background-color: var(--p20);
|
||||
|
||||
}
|
||||
.ͼ4 .cm-line ::selection, .ͼ4 .cm-line::selection{
|
||||
background: var(--p40) !important;
|
||||
}
|
||||
|
||||
.cm-activeLine{
|
||||
|
||||
@@ -22,6 +22,11 @@
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
h3{
|
||||
font-size: 18px;
|
||||
line-height: 28px;
|
||||
}
|
||||
|
||||
ul {
|
||||
padding: 0 0 0 16px;
|
||||
list-style: none outside none;
|
||||
|
||||
+11
-11
@@ -3,7 +3,7 @@
|
||||
namespace Lucent\Account;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Database\Database;
|
||||
use Lucent\Primitive\Collection;
|
||||
use PhpOption\Option;
|
||||
|
||||
@@ -12,7 +12,7 @@ class UserRepo
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return DB::table("users")->count();
|
||||
return Database::make()->table("users")->count();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -20,7 +20,7 @@ class UserRepo
|
||||
*/
|
||||
public function all(): Collection
|
||||
{
|
||||
$usersData = DB::table("users")->get();
|
||||
$usersData = Database::make()->table("users")->get();
|
||||
|
||||
$users = array_map(fn($userData) => $this->fromArray((array)$userData), $usersData->toArray());
|
||||
return new Collection($users);
|
||||
@@ -31,14 +31,14 @@ class UserRepo
|
||||
{
|
||||
$userData = toArray($user);
|
||||
$userData["roles"] = json_encode($userData["roles"]);
|
||||
DB::table("users")->insert($userData);
|
||||
Database::make()->table("users")->insert($userData);
|
||||
}
|
||||
|
||||
public function update(User $user): void
|
||||
{
|
||||
$userData = toArray($user);
|
||||
$userData["roles"] = json_encode($userData["roles"]);
|
||||
DB::table("users")->where("id", $user->id)->update($userData);
|
||||
Database::make()->table("users")->where("id", $user->id)->update($userData);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class UserRepo
|
||||
{
|
||||
$newToken = Token::new(32);
|
||||
|
||||
DB::table("users")
|
||||
Database::make()->table("users")
|
||||
->where("id", $id)
|
||||
->update([
|
||||
'loggedInAt' => Carbon::now()->toJson(),
|
||||
@@ -62,7 +62,7 @@ class UserRepo
|
||||
*/
|
||||
public function findByEmail(Email $email): Option
|
||||
{
|
||||
$user = DB::table("users")->where("email", $email->value())->first();
|
||||
$user = Database::make()->table("users")->where("email", $email->value())->first();
|
||||
|
||||
if (empty($user)) {
|
||||
return none();
|
||||
@@ -76,7 +76,7 @@ class UserRepo
|
||||
*/
|
||||
public function findById(string $id): Option
|
||||
{
|
||||
$user = DB::table("users")->where("id", $id)->first();
|
||||
$user = Database::make()->table("users")->where("id", $id)->first();
|
||||
|
||||
if (empty($user)) {
|
||||
return none();
|
||||
@@ -88,12 +88,12 @@ class UserRepo
|
||||
|
||||
public function updateName(string $userId, Name $name): void
|
||||
{
|
||||
DB::table("users")->where("id", $userId)->update(["name" => $name->value]);
|
||||
Database::make()->table("users")->where("id", $userId)->update(["name" => $name->value]);
|
||||
}
|
||||
|
||||
public function updateEmail(string $userId, Email $email): void
|
||||
{
|
||||
DB::table("users")->where("id", $userId)->update(["email" => $email->value()]);
|
||||
Database::make()->table("users")->where("id", $userId)->update(["email" => $email->value()]);
|
||||
}
|
||||
|
||||
public function fromArray(array $data): User
|
||||
@@ -102,7 +102,7 @@ class UserRepo
|
||||
id: $data["id"],
|
||||
name: new Name($data["name"] ?? ""),
|
||||
email: new Email($data["email"]),
|
||||
roles: json_decode($data["roles"] ?? "[]",true),
|
||||
roles: json_decode($data["roles"] ?? "[]", true),
|
||||
createdAt: $data["createdAt"],
|
||||
updatedAt: $data["updatedAt"],
|
||||
loggedInAt: $data["loggedInAt"] ?? null,
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
namespace Lucent\Command;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Command\Data\CommandLogItem;
|
||||
use Lucent\Database\Database;
|
||||
|
||||
class CommandRepo
|
||||
{
|
||||
public function findBySignature($signature): ?CommandLogItem
|
||||
{
|
||||
|
||||
$row = DB::table("command_logs")->where("signature", $signature)->first();
|
||||
$row = Database::make()->table("command_logs")->where("signature", $signature)->first();
|
||||
if (empty($row)) {
|
||||
return null;
|
||||
}
|
||||
@@ -22,16 +22,16 @@ class CommandRepo
|
||||
{
|
||||
$foundCommandLogItem = $this->findBySignature($commandLogItem->signature);
|
||||
if (empty($foundCommandLogItem)) {
|
||||
DB::table("command_logs")->insert(toArray($commandLogItem));
|
||||
Database::make()->table("command_logs")->insert(toArray($commandLogItem));
|
||||
return;
|
||||
}
|
||||
|
||||
DB::table("command_logs")->where("signature", $commandLogItem->signature)->update(toArray($commandLogItem));
|
||||
Database::make()->table("command_logs")->where("signature", $commandLogItem->signature)->update(toArray($commandLogItem));
|
||||
}
|
||||
|
||||
public function appendToLogs(string $signature, string $line): void
|
||||
{
|
||||
$res = DB::update(
|
||||
Database::make()->update(
|
||||
'update command_logs set logs = logs || ? where signature = ?',
|
||||
[$line, $signature]
|
||||
);
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Lucent\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Lucent\Database\Database;
|
||||
|
||||
class SetupDatabase extends Command
|
||||
{
|
||||
@@ -27,7 +27,7 @@ class SetupDatabase extends Command
|
||||
|
||||
private function tableUsers(): void
|
||||
{
|
||||
Schema::create('users', function (Blueprint $table) {
|
||||
Database::make()->getSchemaBuilder()->create('users', function (Blueprint $table) {
|
||||
$table->uuid("id")->primary();
|
||||
$table->string('name')->nullable();
|
||||
$table->string('email')->unique();
|
||||
@@ -42,7 +42,7 @@ class SetupDatabase extends Command
|
||||
|
||||
private function tableSessions(): void
|
||||
{
|
||||
Schema::create('sessions', function (Blueprint $table) {
|
||||
Database::make()->getSchemaBuilder()->create('sessions', function (Blueprint $table) {
|
||||
$table->string('id')->primary();
|
||||
$table->foreignId('user_id')->nullable()->index();
|
||||
$table->string('ip_address', 45)->nullable();
|
||||
@@ -54,7 +54,7 @@ class SetupDatabase extends Command
|
||||
|
||||
private function tableRecords(): void
|
||||
{
|
||||
Schema::create('records', function (Blueprint $table) {
|
||||
Database::make()->getSchemaBuilder()->create('records', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('schema');
|
||||
$table->string('status');
|
||||
@@ -67,7 +67,7 @@ class SetupDatabase extends Command
|
||||
$table->index('search');
|
||||
});
|
||||
|
||||
Schema::create('edges', function (Blueprint $table) {
|
||||
Database::make()->getSchemaBuilder()->create('edges', function (Blueprint $table) {
|
||||
$table->uuid('source');
|
||||
$table->uuid('target');
|
||||
$table->string('sourceSchema');
|
||||
@@ -81,7 +81,7 @@ class SetupDatabase extends Command
|
||||
|
||||
private function tableRevisions(): void
|
||||
{
|
||||
Schema::create('revisions', function (Blueprint $table) {
|
||||
Database::make()->getSchemaBuilder()->create('revisions', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->uuid('recordId');
|
||||
$table->string('schema');
|
||||
@@ -94,7 +94,7 @@ class SetupDatabase extends Command
|
||||
|
||||
private function tableCommandLogs(): void
|
||||
{
|
||||
Schema::create('command_logs', function (Blueprint $table) {
|
||||
Database::make()->getSchemaBuilder()->create('command_logs', function (Blueprint $table) {
|
||||
$table->uuid('id')->primary();
|
||||
$table->string('signature');
|
||||
$table->integer('pid')->nullable();
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Database;
|
||||
|
||||
use Illuminate\Database\Connection;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class Database
|
||||
{
|
||||
public static function make(): Connection{
|
||||
$dbConnection = config("lucent.database");
|
||||
return DB::connection($dbConnection);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php namespace Lucent\Edge;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Database\Database;
|
||||
use Lucent\LucentException;
|
||||
use PDOException;
|
||||
use stdClass;
|
||||
@@ -15,7 +15,7 @@ class EdgeRepo
|
||||
public function insert(Edge $edge): void
|
||||
{
|
||||
try {
|
||||
DB::table("edges")->insert($edge->toDB());
|
||||
Database::make()->table("edges")->insert($edge->toDB());
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() == 23505) {
|
||||
throw new LucentException("Edge already exists");
|
||||
@@ -34,7 +34,7 @@ class EdgeRepo
|
||||
{
|
||||
$edgesDB = collect($edges)->map(fn($e) => $e->toDB())->toArray();
|
||||
try {
|
||||
DB::table("edges")->insert($edgesDB);
|
||||
Database::make()->table("edges")->insert($edgesDB);
|
||||
} catch (PDOException $e) {
|
||||
if ($e->getCode() == 23505) {
|
||||
throw new LucentException("Edge already exists");
|
||||
@@ -52,8 +52,8 @@ class EdgeRepo
|
||||
public function replaceForRecord(string $from, array $edges): void
|
||||
{
|
||||
$edgesDB = collect($edges)->map(fn($e) => $e->toDB())->toArray();
|
||||
DB::table("edges")->where("source", $from)->delete();
|
||||
DB::table("edges")->insert($edgesDB);
|
||||
Database::make()->table("edges")->where("source", $from)->delete();
|
||||
Database::make()->table("edges")->insert($edgesDB);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,13 +62,13 @@ class EdgeRepo
|
||||
*/
|
||||
public function findAll(): array
|
||||
{
|
||||
$edges = DB::table("edges")->get();
|
||||
$edges = Database::make()->table("edges")->get();
|
||||
return $edges->map([$this, 'mapEdge'])->toArray();
|
||||
}
|
||||
|
||||
public function findForSource(string $recordId): array
|
||||
{
|
||||
$edges = DB::table("edges")->where("source", $recordId)->get();
|
||||
$edges = Database::make()->table("edges")->where("source", $recordId)->get();
|
||||
return $edges->map([$this, 'mapEdge'])->toArray();
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ class EdgeRepo
|
||||
|
||||
public function remove(Edge $edge): void
|
||||
{
|
||||
DB::table("edges")
|
||||
Database::make()->table("edges")
|
||||
->where("source", $edge->source)
|
||||
->where("target", $edge->target)
|
||||
->where("sourceSchema", $edge->sourceSchema)
|
||||
@@ -100,7 +100,7 @@ class EdgeRepo
|
||||
|
||||
public function findLastEdgeRank(string $source, string $field): string
|
||||
{
|
||||
$data = DB::table("edges")
|
||||
$data = Database::make()->table("edges")
|
||||
->where("source", $source)
|
||||
->where("field", $field)
|
||||
->orderBy("rank", "desc")
|
||||
|
||||
@@ -5,11 +5,11 @@ namespace Lucent\File;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Filesystem\Filesystem;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Intervention\Image\ImageManagerStatic;
|
||||
use Lucent\Channel\ChannelService;
|
||||
use Lucent\Database\Database;
|
||||
use Lucent\LucentException;
|
||||
use Lucent\Record\FileData as RecordFile;
|
||||
use Lucent\Record\QueryRecord;
|
||||
@@ -129,7 +129,7 @@ class FileService
|
||||
private function checkDuplicate(string $schemaName, string $checksum, int $filesize): string
|
||||
{
|
||||
|
||||
$record = DB::table("records")
|
||||
$record = Database::make()->table("records")
|
||||
->where("schema", $schemaName)
|
||||
->where("_file->checksum", $checksum)
|
||||
->where("_file->size", $filesize)
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Lucent\Query\DatabaseGraph;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Database\Database;
|
||||
use Lucent\Query\QueryOptions;
|
||||
|
||||
class PgsqlDatabaseGraph implements DatabaseGraph
|
||||
@@ -13,7 +14,7 @@ class PgsqlDatabaseGraph implements DatabaseGraph
|
||||
*/
|
||||
public function getChildren(array $ids, QueryOptions $options): array
|
||||
{
|
||||
$subquery = DB::table('edges AS g')
|
||||
$subquery = Database::make()->table('edges AS g')
|
||||
->select(DB::raw('g.source,g.target,g.rank,"g"."sourceSchema","g"."targetSchema",g.field, 1 as depth '))
|
||||
->whereIn('source', $ids);
|
||||
|
||||
@@ -23,14 +24,14 @@ class PgsqlDatabaseGraph implements DatabaseGraph
|
||||
|
||||
$subquery->limit($options->childrenLimit)
|
||||
->unionAll(
|
||||
DB::table(DB::raw("edges AS g, search_graph AS sg "))
|
||||
Database::make()->table(DB::raw("edges AS g, search_graph AS sg "))
|
||||
->selectRaw('g.source,g.target,g.rank,"g"."sourceSchema","g"."targetSchema",g.field,sg.depth + 1 as depth')
|
||||
->whereRaw("g.source = sg.target")
|
||||
->where("depth", "<", $options->childrenDepth)
|
||||
->orderBy("rank")
|
||||
);
|
||||
|
||||
return DB::table('search_graph')
|
||||
return Database::make()->table('search_graph')
|
||||
// ->select(DB::raw("*, 1 as depth "))
|
||||
->withRecursiveExpression('search_graph', $subquery)
|
||||
->get()->toArray();
|
||||
@@ -41,19 +42,19 @@ class PgsqlDatabaseGraph implements DatabaseGraph
|
||||
*/
|
||||
public function getParents(array $ids, QueryOptions $options): array
|
||||
{
|
||||
$subquery = DB::table('edges AS g')
|
||||
$subquery = Database::make()->table('edges AS g')
|
||||
->select(DB::raw('g.source,g.target,g.rank,"g"."sourceSchema","g"."targetSchema",g.field, 1 as depth '))
|
||||
->limit($options->parentsLimit)
|
||||
->whereIn('g.target', $ids)
|
||||
->unionAll(
|
||||
DB::table(DB::raw("edges AS g, search_graph AS sg "))
|
||||
Database::make()->table(DB::raw("edges AS g, search_graph AS sg "))
|
||||
->selectRaw('g.source,g.target,g.rank,"g"."sourceSchema","g"."targetSchema",g.field,sg.depth + 1 as depth')
|
||||
->whereRaw("g.target = sg.source")
|
||||
->where("depth", "<", $options->parentsDepth)
|
||||
->orderBy("rank")
|
||||
);
|
||||
|
||||
return DB::table('search_graph')
|
||||
return Database::make()->table('search_graph')
|
||||
// ->select(DB::raw('sg.source,sg.target,sg.rank,sg."sourceSchema",sg."targetSchema",sg.field,sg.depth'))
|
||||
->withRecursiveExpression('search_graph', $subquery)
|
||||
->get()->toArray();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
namespace Lucent\Query\DatabaseGraph;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Database\Database;
|
||||
use Lucent\Query\QueryOptions;
|
||||
|
||||
class SqliteDatabaseGraph implements DatabaseGraph
|
||||
@@ -12,7 +13,7 @@ class SqliteDatabaseGraph implements DatabaseGraph
|
||||
*/
|
||||
public function getChildren(array $ids, QueryOptions $options): array
|
||||
{
|
||||
$subquery = DB::table('edges AS g')
|
||||
$subquery = Database::make()->table('edges AS g')
|
||||
->select(DB::raw('g.source,g.target,g.rank,g.sourceSchema,g.targetSchema,g.field, 1 as depth '))
|
||||
->whereIn('source', $ids);
|
||||
|
||||
@@ -22,14 +23,14 @@ class SqliteDatabaseGraph implements DatabaseGraph
|
||||
|
||||
$subquery->limit($options->childrenLimit)
|
||||
->unionAll(
|
||||
DB::table(DB::raw("edges AS g, search_graph AS sg "))
|
||||
Database::make()->table(DB::raw("edges AS g, search_graph AS sg "))
|
||||
->selectRaw('g.source,g.target,g.rank,"g"."sourceSchema","g"."targetSchema",g.field,sg.depth + 1 as depth')
|
||||
->whereRaw("g.source = sg.target")
|
||||
->where("depth", "<", $options->childrenDepth)
|
||||
->orderBy("rank")
|
||||
);
|
||||
|
||||
return DB::table('search_graph')
|
||||
return Database::make()->table('search_graph')
|
||||
// ->select(DB::raw("*, 1 as depth "))
|
||||
->withRecursiveExpression('search_graph', $subquery)
|
||||
->get()->toArray();
|
||||
@@ -40,19 +41,19 @@ class SqliteDatabaseGraph implements DatabaseGraph
|
||||
*/
|
||||
public function getParents(array $ids, QueryOptions $options): array
|
||||
{
|
||||
$subquery = DB::table('edges AS g')
|
||||
$subquery = Database::make()->table('edges AS g')
|
||||
->select(DB::raw('g.source,g.target,g.rank,"g"."sourceSchema","g"."targetSchema",g.field, 1 as depth '))
|
||||
->limit($options->parentsLimit)
|
||||
->whereIn('g.target', $ids)
|
||||
->unionAll(
|
||||
DB::table(DB::raw("edges AS g, search_graph AS sg "))
|
||||
Database::make()->table(DB::raw("edges AS g, search_graph AS sg "))
|
||||
->selectRaw('g.source,g.target,g.rank,"g"."sourceSchema","g"."targetSchema",g.field,sg.depth + 1 as depth')
|
||||
->whereRaw("g.target = sg.source")
|
||||
->where("depth", "<", $options->parentsDepth)
|
||||
->orderBy("rank")
|
||||
);
|
||||
|
||||
return DB::table('search_graph')
|
||||
return Database::make()->table('search_graph')
|
||||
// ->select(DB::raw('sg.source,sg.target,sg.rank,sg."sourceSchema",sg."targetSchema",sg.field,sg.depth'))
|
||||
->withRecursiveExpression('search_graph', $subquery)
|
||||
->get()->toArray();
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace Lucent\Query;
|
||||
|
||||
use Illuminate\Contracts\Foundation\Application;
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Database\Database;
|
||||
use Lucent\Query\BuilderConverter\BuilderConverter;
|
||||
use Lucent\Query\Filter\AndFilter;
|
||||
use Lucent\Query\Filter\Argument;
|
||||
@@ -58,7 +58,7 @@ final class FilterParser
|
||||
}
|
||||
|
||||
$targetIds = collect($graph->records)->pluck("id");
|
||||
$sourceIds = DB::table("edges")->whereIn("target", $targetIds)->where("field", $k)->get()->pluck("source");
|
||||
$sourceIds = Database::make()->table("edges")->whereIn("target", $targetIds)->where("field", $k)->get()->pluck("source");
|
||||
return array_merge($c, $sourceIds->toArray());
|
||||
}, []);
|
||||
|
||||
|
||||
+4
-4
@@ -3,7 +3,7 @@
|
||||
namespace Lucent\Query;
|
||||
|
||||
use Illuminate\Database\Query\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Database\Database;
|
||||
use Lucent\Edge\Edge;
|
||||
use Lucent\Primitive\Collection;
|
||||
use Lucent\Query\DatabaseGraph\DatabaseGraph;
|
||||
@@ -67,7 +67,7 @@ final class Query
|
||||
$edgesIds = collect($resultParentSourceTargetIds)->merge($resultChildrenEdgesTargetIds)->unique()->values()->toArray();
|
||||
$edgeRecords = [];
|
||||
if (!empty($edgesIds)) {
|
||||
$edgeRecords = DB::table('records')
|
||||
$edgeRecords = Database::make()->table('records')
|
||||
->whereIn("id", $edgesIds)
|
||||
->whereIn("status", $this->options->status)
|
||||
->get()->toArray();
|
||||
@@ -142,7 +142,7 @@ final class Query
|
||||
|
||||
private function mainQuery(): array
|
||||
{
|
||||
$query = DB::table("records");
|
||||
$query = Database::make()->table("records");
|
||||
$query = $this->parseFilters($query);
|
||||
$query = $this->findNotLinked($query);
|
||||
|
||||
@@ -189,7 +189,7 @@ final class Query
|
||||
function runWithCount(): Graph
|
||||
{
|
||||
|
||||
$query = DB::table("records");
|
||||
$query = Database::make()->table("records");
|
||||
$query = $this->parseFilters($query);
|
||||
$query = $this->findNotLinked($query);
|
||||
$graph = $this->run();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Lucent\Record;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Database\Database;
|
||||
|
||||
class RecordRepo
|
||||
{
|
||||
@@ -14,7 +14,7 @@ class RecordRepo
|
||||
{
|
||||
$recordToDB = $record->toDB();
|
||||
|
||||
DB::table("records")->insert($recordToDB);
|
||||
Database::make()->table("records")->insert($recordToDB);
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class RecordRepo
|
||||
*/
|
||||
public static function updateStatusBulk(Status $status, array $ids): void
|
||||
{
|
||||
DB::table("records")->whereIn("id", $ids)->update([
|
||||
Database::make()->table("records")->whereIn("id", $ids)->update([
|
||||
'status' => $status->value
|
||||
]);
|
||||
}
|
||||
@@ -31,7 +31,7 @@ class RecordRepo
|
||||
public static function update(Record $record): void
|
||||
{
|
||||
$recordToDB = $record->toDB();
|
||||
DB::table("records")->where("id", $record->id)->update($recordToDB);
|
||||
Database::make()->table("records")->where("id", $record->id)->update($recordToDB);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,17 +43,17 @@ class RecordRepo
|
||||
): void
|
||||
{
|
||||
|
||||
DB::table("records")->whereIn("id", $ids)->delete();
|
||||
DB::table("edges")->whereIn("source", $ids)->delete();
|
||||
DB::table("edges")->whereIn("target", $ids)->delete();
|
||||
DB::table("revisions")->whereIn("recordId", $ids)->delete();
|
||||
Database::make()->table("records")->whereIn("id", $ids)->delete();
|
||||
Database::make()->table("edges")->whereIn("source", $ids)->delete();
|
||||
Database::make()->table("edges")->whereIn("target", $ids)->delete();
|
||||
Database::make()->table("revisions")->whereIn("recordId", $ids)->delete();
|
||||
}
|
||||
|
||||
public function deleteTrashedBySchema(
|
||||
string $schemaName,
|
||||
): void
|
||||
{
|
||||
$ids = DB::table("records")
|
||||
$ids = Database::make()->table("records")
|
||||
->where("schema", $schemaName)
|
||||
->where("status", Status::TRASHED->value)
|
||||
->get()->pluck("id")->toArray();
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace Lucent\Revision;
|
||||
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Database\Database;
|
||||
use Lucent\Edge\Edge;
|
||||
use Lucent\Primitive\Collection;
|
||||
use Lucent\Record\FileData;
|
||||
@@ -19,7 +19,7 @@ class RevisionRepo
|
||||
public function create(Revision $revision): string
|
||||
{
|
||||
$revisionDB = $this->toDB($revision);
|
||||
DB::table($this->table)->insert($revisionDB);
|
||||
Database::make()->table($this->table)->insert($revisionDB);
|
||||
return $revision->id;
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class RevisionRepo
|
||||
**/
|
||||
public function getByRecordId(string $rid): Collection
|
||||
{
|
||||
$revisions = DB::table($this->table)
|
||||
$revisions = Database::make()->table($this->table)
|
||||
->where("recordId", $rid)
|
||||
->get()
|
||||
->map([$this, 'fromDB'])
|
||||
@@ -41,7 +41,7 @@ class RevisionRepo
|
||||
|
||||
public function cleanupRecord(string $rid, int $numKeep): void
|
||||
{
|
||||
$revisionIds = DB::table($this->table)
|
||||
$revisionIds = Database::make()->table($this->table)
|
||||
->where("recordId", $rid)
|
||||
->orderBy("_sys->version", "desc")
|
||||
->limit(100)
|
||||
@@ -49,7 +49,7 @@ class RevisionRepo
|
||||
->get()
|
||||
->pluck("id");
|
||||
|
||||
DB::table($this->table)
|
||||
Database::make()->table($this->table)
|
||||
->whereIn("id", $revisionIds)
|
||||
->delete();
|
||||
}
|
||||
@@ -61,7 +61,7 @@ class RevisionRepo
|
||||
public function getByRecordIdAndVersion(string $rid, int $version): Option
|
||||
{
|
||||
|
||||
$res = DB::table($this->table)
|
||||
$res = Database::make()->table($this->table)
|
||||
->where("recordId", $rid)
|
||||
->where('_sys->version', $version)->first();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace Lucent\Setup\Step;
|
||||
|
||||
use Illuminate\Database\QueryException;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Lucent\Database\Database;
|
||||
use Lucent\Setup\Data\SetupStep;
|
||||
|
||||
class DatabaseSetupStep implements IStep
|
||||
@@ -13,21 +13,18 @@ class DatabaseSetupStep implements IStep
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$name = "Database Connection";
|
||||
|
||||
$databaseConnectionName = config("lucent.database");
|
||||
|
||||
|
||||
$databaseConfig = config('database.connections.lucentdb');
|
||||
if(empty($databaseConfig)) {
|
||||
$databaseConfig = config('database.connections.'.$databaseConnectionName);
|
||||
if (empty($databaseConfig)) {
|
||||
$instructions = <<<EOD
|
||||
# You need to setup a database connection for lucentdb in database.php config. You can choose either sqlite or pgsql
|
||||
# You need to setup a database connection for $databaseConnectionName in database.php config. You can choose either sqlite or pgsql
|
||||
# example:
|
||||
|
||||
'connections' => [
|
||||
'lucentdb' => [
|
||||
'$databaseConnectionName' => [
|
||||
'driver' => 'sqlite',
|
||||
'url' => env('LUCENT_DATABASE_URL'),
|
||||
'database' => env('LUCENT_DB_DATABASE', database_path('database.sqlite')),
|
||||
@@ -39,8 +36,8 @@ EOD;
|
||||
}
|
||||
|
||||
try {
|
||||
DB::connection("lucentdb")->table("records")->get();
|
||||
}catch (QueryException $e) {
|
||||
Database::make()->table("records")->get();
|
||||
} catch (QueryException $e) {
|
||||
$instructions = <<<EOD
|
||||
# Make sure you run:
|
||||
php artisan lucent:setup-db
|
||||
|
||||
Reference in New Issue
Block a user