Skip to content

Commit 669ec54

Browse files
authored
v5.2.0 updates (#38)
1 parent 9ddd82b commit 669ec54

File tree

10 files changed

+59
-20
lines changed

10 files changed

+59
-20
lines changed

CHANGELOG.md

+10
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- `Fixed` for any bug fixes.
1313
- `Security` in case of vulnerabilities
1414

15+
## [5.2.0]- 2024.09.16
16+
17+
### Added
18+
19+
- Added support for using a specific database connection name with `migrate:up`, `migrate:down` and `migration:list` console commands.
20+
21+
### Changed
22+
23+
- Updated `simple-pdo` dependency to v5.0.0.
24+
1525
## [5.1.1]- 2024.09.10
1626

1727
### Fixed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"bayfrontmedia/php-http-response": "^2.0",
4242
"bayfrontmedia/php-time-helpers": "^2.0",
4343
"bayfrontmedia/route-it": "^3.1",
44-
"bayfrontmedia/simple-pdo": "^4.0",
44+
"bayfrontmedia/simple-pdo": "^5.0",
4545
"bayfrontmedia/veil": "^2.1",
4646
"filp/whoops": "^2.15",
4747
"symfony/console": "^7.1",

composer.lock

+13-13
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/services/db.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ configuration array exists at `/config/database.php`.
1010

1111
```php
1212
use Bayfront\Bones\Application\Utilities\App;
13+
use Bayfront\SimplePdo\Db;
1314

1415
$options = [];
1516

@@ -21,8 +22,7 @@ if (App::getEnv('DB_SECURE_TRANSPORT')) {
2122
}
2223

2324
return [
24-
'primary' => [ // Connection name
25-
'default' => true, // One connection on the array must be defined as default
25+
Db::DB_DEFAULT => [ // Connection name
2626
'adapter' => App::getEnv('DB_ADAPTER'), // Adapter to use
2727
'host' => App::getEnv('DB_HOST'),
2828
'port' => App::getEnv('DB_PORT'),

docs/usage/console.md

+6
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,24 @@ php bones make:service NAME
115115

116116
# Rollback database migrations
117117
php bones migrate:down
118+
# Migrate down with specific database name
119+
php bones migrate:down --db=DATABASE_NAME
118120
# Rollback database migrations to a specific batch
119121
php bones migrate:down --batch=BATCH
120122
# Use --force to skip confirmation prompt
121123
php bones migrate:down --force
122124

123125
# Run all pending database migrations
124126
php bones migrate:up
127+
# Migrate up with specific database name
128+
php bones migrate:up --db=DATABASE_NAME
125129
# Use --force to skip confirmation prompt
126130
php bones migrate:up --force
127131

128132
# List all migrations which have ran
129133
php bones migration:list
134+
# List all migrations for a specific database name
135+
php bones migration:list --db=DATABASE_NAME
130136
# Migrations can be sorted by "id", "name", or "batch" (default)
131137
php bones migration:list --sort=id
132138
# Return as JSON

resources/cli/templates/install/service/db/config/database.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
use Bayfront\Bones\Application\Utilities\App;
9+
use Bayfront\SimplePdo\Db;
910

1011
$options = [];
1112

@@ -17,8 +18,7 @@
1718
}
1819

1920
return [
20-
'primary' => [ // Connection name
21-
'default' => true, // One connection on the array must be defined as default
21+
Db::DB_DEFAULT => [ // Connection name
2222
'adapter' => App::getEnv('DB_ADAPTER'), // Adapter to use
2323
'host' => App::getEnv('DB_HOST'),
2424
'port' => App::getEnv('DB_PORT'),

src/Application/Kernel/Console/Commands/MigrateDown.php

+7
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ protected function configure(): void
3939

4040
$this->setName('migrate:down')
4141
->setDescription('Rollback database migrations')
42+
->addOption('db', null, InputOption::VALUE_REQUIRED)
4243
->addOption('batch', null, InputOption::VALUE_REQUIRED)
4344
->addOption('force', null, InputOption::VALUE_NONE);
4445

@@ -54,6 +55,12 @@ protected function configure(): void
5455
protected function execute(InputInterface $input, OutputInterface $output): int
5556
{
5657

58+
$db = (string)$input->getOption('db');
59+
60+
if ($db !== '') {
61+
$this->db->useConnection($db);
62+
}
63+
5764
$batch = (int)$input->getOption('batch');
5865

5966
if ($batch == 0) {

src/Application/Kernel/Console/Commands/MigrateUp.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ protected function configure(): void
3939

4040
$this->setName('migrate:up')
4141
->setDescription('Run all pending database migrations')
42+
->addOption('db', null, InputOption::VALUE_REQUIRED)
4243
->addOption('force', null, InputOption::VALUE_NONE);
4344

4445
}
@@ -60,7 +61,15 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6061
return Command::SUCCESS;
6162
}
6263

63-
// Migration files exist. Ensure database table exists.
64+
// Migration files exist.
65+
66+
$db = (string)$input->getOption('db');
67+
68+
if ($db !== '') {
69+
$this->db->useConnection($db);
70+
}
71+
72+
// Ensure database table exists.
6473

6574
$this->db->query("CREATE TABLE IF NOT EXISTS `migrations` (
6675
`id` int NOT NULL AUTO_INCREMENT PRIMARY KEY,

src/Application/Kernel/Console/Commands/MigrationList.php

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ protected function configure(): void
3131

3232
$this->setName('migration:list')
3333
->setDescription('List all migrations which have ran')
34+
->addOption('db', null, InputOption::VALUE_REQUIRED)
3435
->addOption('sort', null, InputOption::VALUE_REQUIRED)
3536
->addOption('json', null, InputOption::VALUE_NONE);
3637

@@ -46,6 +47,12 @@ protected function configure(): void
4647
protected function execute(InputInterface $input, OutputInterface $output): int
4748
{
4849

50+
$db = (string)$input->getOption('db');
51+
52+
if ($db !== '') {
53+
$this->db->useConnection($db);
54+
}
55+
4956
try {
5057
$return = $this->db->select("SELECT id, name, batch FROM `migrations` ORDER BY batch, name");
5158
} catch (Exception) {

src/Bones.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public function start(string $interface): void
150150
Constants::define('APP_STORAGE_PATH', Constants::get('APP_BASE_PATH') . '/storage');
151151
Constants::define('BONES_BASE_PATH', rtrim(dirname(__FILE__, 2), '/'));
152152
Constants::define('BONES_RESOURCES_PATH', Constants::get('BONES_BASE_PATH') . '/resources');
153-
Constants::define('BONES_VERSION', '5.1.1');
153+
Constants::define('BONES_VERSION', '5.2.0');
154154
// ------------------------- Load environment variables -------------------------
155155

156156
if (file_exists(App::basePath('/.env'))) {

0 commit comments

Comments
 (0)