Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
limwa committed Jul 17, 2024
1 parent 0b85ba8 commit aecca4c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
37 changes: 37 additions & 0 deletions app/Console/Commands/CreateDbSchema.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class CreateDbSchema extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'app:create-db-schema';

/**
* The console command description.
*
* @var string
*/
protected $description = 'Command description';

/**
* Execute the console command.
*/
public function handle()
{
$conn = DB::connectUsing("pgsql", [
...config('database.connections.pgsql'),
'search_path' => "public",
]);

$search_path = config('database.connections.pgsql.search_path');
$conn->statement("CREATE SCHEMA IF NOT EXISTS $search_path");
}
}
2 changes: 1 addition & 1 deletion config/database.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
'charset' => 'utf8',
'prefix' => '',
'prefix_indexes' => true,
'search_path' => env('DB_SEARCH_PATH', 'public'),
'search_path' => str_replace('-', '_', env('DB_SEARCH_PATH', 'public')),
'sslmode' => 'prefer',
],

Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/Dockerfile.seeder
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ RUN [ -z "${LARAVEL_ENV_FILE_KEY}" ] || php artisan env:decrypt -n --env=${LARAV
COPY public/ ./public/
COPY storage/ ./storage/

CMD ["php", "artisan", "migrate", "-n", "--force"]
CMD [ "sh", "-c", "php artisan app:create-db-schema && php artisan migrate -n"]

0 comments on commit aecca4c

Please sign in to comment.