-
. |
Beta Was this translation helpful? Give feedback.
Answered by
rawilk
Nov 7, 2024
Replies: 1 comment
-
I had a similar use case and I solved it adding extra dump options to the config for my database connection. In my use case, I actually have several tables that I want to include the schema for, but without the data. Here is a simplified version of my custom command I wrote to do this particular snapshot: public function handle()
{
$productionConnectionName = config('database.default');
config()->set('database.connections.{$productionConnectionName}.dump", [
'addExtraOption' => $this->buildDumpOptions(),
]);
$this->call(Create::class, [
'--connection' => $productionConnectionName,
]);
}
protected function buildDumpOptions(): string
{
$options = [
'--no-owner',
...array_map(
fn (string $table) => "--exclude-table-data={$table}",
config('site.staging.exclude_tables'),
),
];
return implode(' ', $options);
} Note: My application is using postgres, so the |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
kasteckis
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had a similar use case and I solved it adding extra dump options to the config for my database connection. In my use case, I actually have several tables that I want to include the schema for, but without the data. Here is a simplified version of my custom command I wrote to do this particular snapshot: