Skip to content

Commit cac1809

Browse files
committed
Merge branch 'dev' of https://github.com/WebFiori/framework into dev
2 parents 4fa8188 + 863929b commit cac1809

File tree

7 files changed

+46
-44
lines changed

7 files changed

+46
-44
lines changed

.github/workflows/php80.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build PHP 8.0
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ main ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ main ]
88

99
jobs:
1010
test:
@@ -13,7 +13,7 @@ jobs:
1313
sql.data:
1414
image: mcr.microsoft.com/mssql/server:2019-latest
1515
env:
16-
SA_PASSWORD: 1234567890@Eu
16+
SA_PASSWORD: ${{secrets.SA_PASSWORD}}
1717
ACCEPT_EULA: Y
1818
MSSQL_PID: Express
1919
ports:
@@ -45,9 +45,9 @@ jobs:
4545
with:
4646
mysql version: '5.7'
4747
mysql database: 'testing_db'
48-
mysql root password: 123456
48+
mysql root password: ${{secrets.MYSQL_ROOT_PASSWORD}}
4949
mysql user: 'root'
50-
mysql password: 123456
50+
mysql password: ${{secrets.MYSQL_ROOT_PASSWORD}}
5151

5252
- name: Wait for MySQL
5353
run: |
@@ -61,7 +61,7 @@ jobs:
6161
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
6262
sudo apt update
6363
sudo apt install mssql-tools18
64-
/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 1234567890@Eu -Q 'create database testing_db' -C
64+
/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P ${{secrets.SA_PASSWORD}} -Q 'create database testing_db' -C
6565
6666
- name: Install Dependencies
6767
run: composer install --prefer-dist --no-interaction --no-dev

.github/workflows/php81.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build PHP 8.1
22

33
on:
44
push:
5-
branches: [ master ]
5+
branches: [ main ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ main ]
88

99
jobs:
1010
test:
@@ -13,11 +13,9 @@ jobs:
1313
sql.data:
1414
image: mcr.microsoft.com/mssql/server:2019-latest
1515
env:
16-
SA_PASSWORD: 1234567890@Eu
16+
SA_PASSWORD: ${{secrets.SA_PASSWORD}}
1717
ACCEPT_EULA: Y
1818
MSSQL_PID: Express
19-
ports:
20-
- "1433:1433"
2119
strategy:
2220
fail-fast: true
2321
matrix:
@@ -45,9 +43,9 @@ jobs:
4543
with:
4644
mysql version: '5.7'
4745
mysql database: 'testing_db'
48-
mysql root password: 123456
46+
mysql root password: ${{secrets.MYSQL_ROOT_PASSWORD}}
4947
mysql user: 'root'
50-
mysql password: 123456
48+
mysql password: ${{secrets.MYSQL_ROOT_PASSWORD}}
5149

5250
- name: Wait for MySQL
5351
run: |
@@ -61,7 +59,7 @@ jobs:
6159
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
6260
sudo apt update
6361
sudo apt install mssql-tools18
64-
/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 1234567890@Eu -Q 'create database testing_db' -C
62+
/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P ${{secrets.SA_PASSWORD}} -Q 'create database testing_db' -C
6563
6664
- name: Install Dependencies
6765
run: composer install --prefer-dist --no-interaction --no-dev

.github/workflows/php82.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build PHP 8.2
22

33
on:
44
push:
5-
branches: [ master, dev ]
5+
branches: [ main, dev ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ main ]
88

99
jobs:
1010

@@ -14,7 +14,7 @@ jobs:
1414
sql.data:
1515
image: mcr.microsoft.com/mssql/server:2019-latest
1616
env:
17-
SA_PASSWORD: 1234567890@Eu
17+
SA_PASSWORD: ${{secrets.SA_PASSWORD}}
1818
ACCEPT_EULA: Y
1919
MSSQL_PID: Express
2020
ports:
@@ -46,9 +46,9 @@ jobs:
4646
with:
4747
mysql version: '5.7'
4848
mysql database: 'testing_db'
49-
mysql root password: 123456
49+
mysql root password: ${{secrets.MYSQL_ROOT_PASSWORD}}
5050
mysql user: 'root'
51-
mysql password: 123456
51+
mysql password: ${{secrets.MYSQL_ROOT_PASSWORD}}
5252

5353
- name: Wait for MySQL
5454
run: |
@@ -62,7 +62,7 @@ jobs:
6262
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
6363
sudo apt update
6464
sudo apt install mssql-tools18
65-
/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 1234567890@Eu -Q 'create database testing_db' -C
65+
/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P ${{secrets.SA_PASSWORD}} -Q 'create database testing_db' -C
6666
6767
- name: Install Dependencies
6868
run: composer install --prefer-dist --no-interaction --no-dev

.github/workflows/php83.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build PHP 8.3
22

33
on:
44
push:
5-
branches: [ master, dev ]
5+
branches: [ main, dev ]
66
pull_request:
7-
branches: [ master, dev ]
7+
branches: [ main, dev ]
88

99
jobs:
1010

@@ -14,11 +14,9 @@ jobs:
1414
sql.data:
1515
image: mcr.microsoft.com/mssql/server:2019-latest
1616
env:
17-
SA_PASSWORD: 1234567890@Eu
17+
SA_PASSWORD: ${{secrets.SA_PASSWORD}}
1818
ACCEPT_EULA: Y
1919
MSSQL_PID: Express
20-
ports:
21-
- "1433:1433"
2220
strategy:
2321
fail-fast: true
2422
matrix:
@@ -46,9 +44,9 @@ jobs:
4644
with:
4745
mysql version: '5.7'
4846
mysql database: 'testing_db'
49-
mysql root password: 123456
47+
mysql root password: ${{secrets.MYSQL_ROOT_PASSWORD}}
5048
mysql user: 'root'
51-
mysql password: 123456
49+
mysql password: ${{secrets.MYSQL_ROOT_PASSWORD}}
5250

5351
- name: Wait for MySQL
5452
run: |
@@ -62,7 +60,7 @@ jobs:
6260
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
6361
sudo apt update
6462
sudo apt install mssql-tools18
65-
/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 1234567890@Eu -Q 'create database testing_db' -C
63+
/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P ${{secrets.SA_PASSWORD}} -Q 'create database testing_db' -C
6664
6765
- name: Install Dependencies
6866
run: composer install --prefer-dist --no-interaction --no-dev

.github/workflows/php84.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Build PHP 8.4
22

33
on:
44
push:
5-
branches: [ master, dev ]
5+
branches: [ main, dev ]
66
pull_request:
7-
branches: [ master ]
7+
branches: [ main ]
88

99
jobs:
1010

@@ -14,7 +14,7 @@ jobs:
1414
sql.data:
1515
image: mcr.microsoft.com/mssql/server:2019-latest
1616
env:
17-
SA_PASSWORD: 1234567890@Eu
17+
SA_PASSWORD: ${{secrets.SA_PASSWORD}}
1818
ACCEPT_EULA: Y
1919
MSSQL_PID: Express
2020
ports:
@@ -46,9 +46,9 @@ jobs:
4646
with:
4747
mysql version: '5.7'
4848
mysql database: 'testing_db'
49-
mysql root password: 123456
49+
mysql root password: ${{secrets.MYSQL_ROOT_PASSWORD}}
5050
mysql user: 'root'
51-
mysql password: 123456
51+
mysql password: ${{secrets.MYSQL_ROOT_PASSWORD}}
5252

5353
- name: Wait for MySQL
5454
run: |
@@ -62,7 +62,7 @@ jobs:
6262
curl https://packages.microsoft.com/config/ubuntu/22.04/prod.list | sudo tee /etc/apt/sources.list.d/mssql-release.list
6363
sudo apt update
6464
sudo apt install mssql-tools18
65-
/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P 1234567890@Eu -Q 'create database testing_db' -C
65+
/opt/mssql-tools18/bin/sqlcmd -S localhost -U SA -P ${{secrets.SA_PASSWORD}} -Q 'create database testing_db' -C
6666
6767
- name: Install Dependencies
6868
run: composer install --prefer-dist --no-interaction --no-dev

tests/webfiori/framework/test/cli/RunMigrationsCommantTest.php

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function testRunMigrations03() {
107107
"Error: Invalid answer.\n",
108108
"Select database connection:\n",
109109
"0: default-conn <--\n",
110-
"Error: Unable to connect to database: 18456 - [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'sa'.\n",
110+
"Error: Unable to connect to database: 18456 - [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Login failed for user 'sa'.\n",
111111
], $output);
112112
$this->assertEquals(-1, $this->getExitCode());
113113

@@ -169,7 +169,7 @@ public function testRunMigrations07() {
169169
"Error: Invalid answer.\n",
170170
"Select database connection:\n",
171171
"0: default-conn <--\n",
172-
"Error: Unable to connect to database: 4060 - [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Cannot open database \"testing_dbx\" requested by the login. The login failed.\n",
172+
"Error: Unable to connect to database: 4060 - [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Cannot open database \"testing_dbx\" requested by the login. The login failed.\n",
173173
], $this->executeMultiCommand([
174174
RunMigrationsCommand::class,
175175
'--ns' => '\\app\\database\\migrations',
@@ -212,7 +212,7 @@ public function testRunMigrations08() {
212212
"0: default-conn <--\n",
213213
"Starting to execute migrations...\n",
214214
"Error: Failed to execute migration due to following:\n",
215-
"208 - [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Invalid object name 'migrations'. (Line 361)\n",
215+
"208 - [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Invalid object name 'migrations'. (Line 361)\n",
216216
"Warning: Execution stopped.\n",
217217
"Info: No migrations were executed.\n"
218218
], $output);
@@ -268,7 +268,7 @@ public function testRunMigrations10() {
268268
'TrustServerCertificate' => 'true'
269269
]);
270270
$conn->setName('default-conn');
271-
$clazz = $this->createMigration('Cool One');
271+
$clazz = $this->createMigration('Cool One', 'CLSOne');
272272
$this->assertTrue(class_exists($clazz));
273273
App::getConfig()->addOrUpdateDBConnection($conn);
274274
$output = $this->executeMultiCommand([
@@ -304,7 +304,7 @@ public function testRunMigrations11() {
304304
'TrustServerCertificate' => 'true'
305305
]);
306306
$conn->setName('default-conn');
307-
$clazz = $this->createMigration('Cool One');
307+
$clazz = $this->createMigration('Cool One', 'ColOne');
308308
$this->assertTrue(class_exists($clazz));
309309
App::getConfig()->addOrUpdateDBConnection($conn);
310310
$output = $this->executeMultiCommand([
@@ -359,7 +359,7 @@ public function testRunMigrations12() {
359359
"0: default-conn <--\n",
360360
"Initializing migrations table...\n",
361361
"Error: Unable to create migrations table due to following:\n",
362-
"Unable to connect to database: 18456 - [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]Login failed for user 'sa'.\n",
362+
"Unable to connect to database: 18456 - [Microsoft][ODBC Driver 18 for SQL Server][SQL Server]Login failed for user 'sa'.\n",
363363
], $output);
364364
$this->assertEquals(-1, $this->getExitCode());
365365

@@ -433,6 +433,9 @@ public function testRunMigrations15() {
433433
*/
434434
public function testRunMigrations16() {
435435
$this->assertEquals([
436+
"Checking namespace '\app\database\migrations\multi' for migrations...\n",
437+
"Info: Found 3 migration(s) in the namespace '\app\database\migrations\multi'.\n",
438+
"Starting to execute migrations...\n",
436439
"Info: No migrations were executed.\n",
437440
], $this->executeMultiCommand([
438441
RunMigrationsCommand::class,
@@ -451,7 +454,7 @@ public function testRunMigrations17() {
451454
RunMigrationsCommand::class,
452455
'--runner' => '\\app\\database\\migrations\\multi\Migration000',
453456
]));
454-
$this->assertEquals(-2, $this->getExitCode());
457+
$this->assertEquals(-1, $this->getExitCode());
455458
}
456459
/**
457460
* @test

webfiori/framework/cli/commands/RunMigrationsCommand.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,16 @@ private function checkMigrationsTable(?MigrationsRunner $runner, $conn = null) {
7878
$conn = $this->getDBConnection($runner);
7979
}
8080
if ($conn !== null) {
81-
$temp = $runner !== null ? $runner : new MigrationsRunner(APP_PATH, '\\'.APP_DIR, $conn);
81+
8282
try {
8383
$this->println("Initializing migrations table...");
84+
$temp = $runner !== null ? $runner : new MigrationsRunner(APP_PATH, '\\'.APP_DIR, $conn);
85+
8486
$temp->createMigrationsTable();
8587
$this->success("Migrations table succesfully created.");
86-
} catch (Throwable $ex) {
87-
$this->error('Unable to create migrations table: '.$ex->getMessage());
88+
} catch (\Throwable $ex) {
89+
$this->error('Unable to create migrations table due to following:');
90+
$this->println($ex->getMessage());
8891
return -1;
8992
}
9093
return 0;

0 commit comments

Comments
 (0)